@@ -148,7 +148,7 @@ internal C(string fileName)
148148 [ Test ]
149149 public static void WhenAddedToFormComponents ( )
150150 {
151- var code = @"
151+ var syntaxTree = CSharpSyntaxTree . ParseText ( @"
152152namespace N
153153{
154154 using System.IO;
@@ -163,14 +163,37 @@ public class Winform : Form
163163 this.components.Add(stream);
164164 }
165165 }
166- }" ;
167- var syntaxTree = CSharpSyntaxTree . ParseText ( code ) ;
166+ }" ) ;
168167 var compilation = CSharpCompilation . Create ( "test" , new [ ] { syntaxTree } , MetadataReferences . FromAttributes ( ) ) ;
169168 var semanticModel = compilation . GetSemanticModel ( syntaxTree ) ;
170169 var value = syntaxTree . FindVariableDeclaration ( "stream = File.OpenRead(string.Empty)" ) ;
171170 Assert . AreEqual ( true , semanticModel . TryGetSymbol ( value , CancellationToken . None , out ILocalSymbol symbol ) ) ;
172171 Assert . AreEqual ( true , Disposable . Disposes ( symbol , semanticModel , CancellationToken . None ) ) ;
173172 }
173+
174+ [ Test ]
175+ public static void IgnoreNewFormShow ( )
176+ {
177+ var syntaxTree = CSharpSyntaxTree . ParseText ( @"
178+ namespace N
179+ {
180+ using System.Windows.Forms;
181+
182+ public class Winform : Form
183+ {
184+ public static void M()
185+ {
186+ var form = new Winform();
187+ form.Show();
188+ }
189+ }
190+ }" ) ;
191+ var compilation = CSharpCompilation . Create ( "test" , new [ ] { syntaxTree } , MetadataReferences . FromAttributes ( ) ) ;
192+ var semanticModel = compilation . GetSemanticModel ( syntaxTree ) ;
193+ var value = syntaxTree . FindVariableDeclaration ( "var form = new Winform()" ) ;
194+ Assert . AreEqual ( true , semanticModel . TryGetSymbol ( value , CancellationToken . None , out ILocalSymbol symbol ) ) ;
195+ Assert . AreEqual ( true , Disposable . Disposes ( symbol , semanticModel , CancellationToken . None ) ) ;
196+ }
174197 }
175198 }
176199}
0 commit comments