@@ -96,5 +96,79 @@ public class Test
9696
9797 Assert . True ( signature1 . HasLocalTypeReference ) ;
9898 }
99+
100+ [ Fact ]
101+ public void Matches_IsTrue_WhenUsingLocalTypesAsGenericArguments ( )
102+ {
103+ var function1 = @"using System;
104+ using System.Collections.Generic;
105+ public static void Run(string id, ICollection<Test> test1)
106+ {
107+
108+ }
109+
110+ public class Test
111+ {
112+ public string Id { get; set; }
113+ }" ;
114+
115+ var tree = CSharpSyntaxTree . ParseText ( function1 , CSharpParseOptions . Default . WithKind ( SourceCodeKind . Script ) ) ;
116+ var references = new MetadataReference [ ] { MetadataReference . CreateFromFile ( typeof ( string ) . Assembly . Location ) } ;
117+ var compilation = CSharpCompilation . Create ( "test1" , references : references ) . AddSyntaxTrees ( tree ) ;
118+
119+ var signature1 = CSharpFunctionSignature . FromCompilation ( compilation , new FunctionEntryPointResolver ( ) ) ;
120+
121+ Assert . True ( signature1 . HasLocalTypeReference ) ;
122+ }
123+
124+ [ Fact ]
125+ public void Matches_IsTrue_WhenUsingLocalTypesAsDeepGenericArguments ( )
126+ {
127+ var function1 = @"using System;
128+ using System.Threading.Tasks;
129+ using System.Collections.Generic;
130+ public static void Run(string id, ICollection<Task<Test>> test1)
131+ {
132+
133+ }
134+
135+ public class Test
136+ {
137+ public string Id { get; set; }
138+ }" ;
139+
140+ var tree = CSharpSyntaxTree . ParseText ( function1 , CSharpParseOptions . Default . WithKind ( SourceCodeKind . Script ) ) ;
141+ var references = new MetadataReference [ ] { MetadataReference . CreateFromFile ( typeof ( string ) . Assembly . Location ) } ;
142+ var compilation = CSharpCompilation . Create ( "test1" , references : references ) . AddSyntaxTrees ( tree ) ;
143+
144+ var signature1 = CSharpFunctionSignature . FromCompilation ( compilation , new FunctionEntryPointResolver ( ) ) ;
145+
146+ Assert . True ( signature1 . HasLocalTypeReference ) ;
147+ }
148+
149+ [ Fact ]
150+ public void Matches_IsFalse_WhenNotUsingLocalTypes ( )
151+ {
152+ var function1 = @"using System;
153+ using System.Threading.Tasks;
154+ using System.Collections.Generic;
155+ public static void Run(string id, int test1)
156+ {
157+
158+ }
159+
160+ public class Test
161+ {
162+ public string Id { get; set; }
163+ }" ;
164+
165+ var tree = CSharpSyntaxTree . ParseText ( function1 , CSharpParseOptions . Default . WithKind ( SourceCodeKind . Script ) ) ;
166+ var references = new MetadataReference [ ] { MetadataReference . CreateFromFile ( typeof ( string ) . Assembly . Location ) } ;
167+ var compilation = CSharpCompilation . Create ( "test1" , references : references ) . AddSyntaxTrees ( tree ) ;
168+
169+ var signature1 = CSharpFunctionSignature . FromCompilation ( compilation , new FunctionEntryPointResolver ( ) ) ;
170+
171+ Assert . False ( signature1 . HasLocalTypeReference ) ;
172+ }
99173 }
100174}
0 commit comments