@@ -36,6 +36,11 @@ internal sealed class GenerateInteropFormCommand
3636 /// </summary>
3737 private readonly Package package ;
3838
39+ /// <summary>
40+ /// Warning message presented flag for unsupported parameter types
41+ /// </summary>
42+ private bool DisplayWarningPresented = false ;
43+
3944 /// <summary>
4045 /// Initializes a new instance of the <see cref="GenerateInteropFormCommand"/> class.
4146 /// Adds our command handlers for menu (commands must exist in the command table file)
@@ -164,6 +169,11 @@ private void CreateInteropFormProxiesForProject(Project currentAssembly, Project
164169 private void CreateInteropFormProxiesForDocument ( List < CodeClass > interopFormClasses , Project currentAssembly , ProjectItem interopFormDoc )
165170 {
166171
172+ if ( checkFileExists ( currentAssembly , interopFormDoc ) )
173+ {
174+ return ;
175+ }
176+
167177 if ( interopFormClasses . Count <= 0 )
168178 return ;
169179
@@ -173,6 +183,7 @@ private void CreateInteropFormProxiesForDocument(List<CodeClass> interopFormClas
173183 namespace1 . Name = "Interop" ;
174184 unit1 . Namespaces . Add ( namespace1 ) ;
175185 namespace1 . Imports . Add ( import1 ) ;
186+ namespace1 . Imports . Add ( new CodeNamespaceImport ( "System" ) ) ;
176187 foreach ( CodeClass class1 in interopFormClasses )
177188 {
178189 string text2 = class1 . FullName ;
@@ -258,9 +269,9 @@ private void CreateInteropFormProxiesForDocument(List<CodeClass> interopFormClas
258269 declaration1 . CustomAttributes . Add ( new CodeAttributeDeclaration ( "System.Runtime.InteropServices.ComSourceInterfaces" , new System . CodeDom . CodeAttributeArgument [ ] { new System . CodeDom . CodeAttributeArgument ( new CodeTypeOfExpression ( declaration2 . Name ) ) } ) ) ;
259270 }
260271 }
261-
262-
272+
263273 ProjectItem generatedFolderItem = GetGeneratedFolderItem ( currentAssembly ) ;
274+
264275 FileInfo generatedItemInfo = getGeneratedItem ( currentAssembly , generatedFolderItem , interopFormDoc ) ;
265276
266277 StreamWriter writer1 = new StreamWriter ( generatedItemInfo . Create ( ) ) ;
@@ -285,7 +296,7 @@ private FileInfo getGeneratedItem(Project currentAssembly, ProjectItem generated
285296 {
286297 d . Create ( ) ;
287298 }
288-
299+
289300 FileInfo infoGeneratedItem = new FileInfo ( fullName ) ;
290301 foreach ( ProjectItem item in generatedFolderItem . ProjectItems )
291302 {
@@ -382,12 +393,18 @@ private void AddInitializeMethodForConstructor(CodeTypeDeclaration proxyClass, C
382393 bool flag1 = false ;
383394 foreach ( CodeParameter parameter1 in method . Parameters )
384395 {
396+ var paramType = parameter1 . Type . AsFullName ;
385397 if ( ! this . IsSupported ( parameter1 . Type ) )
386398 {
387- this . DisplayWarning ( String . Format ( Resource . InitMethodErrMsg , parameter1 . Type . AsFullName , parameter1 . Name , parameter1 . Type . AsFullName ) ) ;
388- return ;
399+ if ( ! DisplayWarningPresented )
400+ {
401+ this . DisplayWarning ( String . Format ( Resource . InitMethodWarningMsg ) ) ;
402+ DisplayWarningPresented = true ;
403+ }
404+ paramType = "Object" ;
405+
389406 }
390- CodeParameterDeclarationExpression expression1 = new CodeParameterDeclarationExpression ( parameter1 . Type . AsFullName , parameter1 . Name ) ;
407+ CodeParameterDeclarationExpression expression1 = new CodeParameterDeclarationExpression ( paramType , parameter1 . Name ) ;
391408 method1 . Parameters . Add ( expression1 ) ;
392409 if ( flag1 )
393410 {
@@ -712,6 +729,24 @@ private List<CodeClass> GetInteropFormClasses(Project assemblyProj, ProjectItem
712729 return list2 ;
713730 }
714731
732+ private bool checkFileExists ( Project currentAssembly , ProjectItem interopFormDoc )
733+ {
734+ FileInfo infoProjectItem = new FileInfo ( interopFormDoc . get_FileNames ( 0 ) ) ;
735+ string name = infoProjectItem . Name . Replace ( infoProjectItem . Extension , ".wrapper" + infoProjectItem . Extension ) ;
736+ string folder = Path . GetDirectoryName ( infoProjectItem . FullName . Replace ( Path . GetDirectoryName ( currentAssembly . FullName ) , Path . GetDirectoryName ( currentAssembly . FullName )
737+ + @"\" + Resource . INTEROP_FORM_PROXY_FOLDER_NAME ) ) ;
738+ string fullName = folder + @"\" + name ;
739+
740+ if ( File . Exists ( fullName ) )
741+ {
742+ return true ;
743+ }
744+ else
745+ {
746+ return false ;
747+ }
748+ }
749+
715750 private DTE2 _applicationObject ;
716751 private System . Type _attrTypeEvent ;
717752 private System . Type _attrTypeForm ;
0 commit comments