@@ -61,6 +61,28 @@ public bool UseImplicitUsings
6161 }
6262 }
6363
64+ private bool useWpf = false ;
65+
66+ public bool UseWpf
67+ {
68+ get
69+ {
70+ initialize . Run ( ) ;
71+ return useWpf ;
72+ }
73+ }
74+
75+ private bool useWindowsForms = false ;
76+
77+ public bool UseWindowsForms
78+ {
79+ get
80+ {
81+ initialize . Run ( ) ;
82+ return useWindowsForms ;
83+ }
84+ }
85+
6486 private bool isLegacyProjectStructureUsed = false ;
6587
6688 public bool IsLegacyProjectStructureUsed
@@ -105,10 +127,10 @@ internal FileContent(ILogger logger,
105127 public FileContent ( ILogger logger , IEnumerable < string > files ) : this ( logger , files , new UnsafeFileReader ( ) )
106128 { }
107129
108- private static string GetGroup ( ReadOnlySpan < char > input , ValueMatch valueMatch , string groupPrefix , bool toLower )
130+ private static string GetGroup ( ReadOnlySpan < char > input , ValueMatch valueMatch , string groupPrefix )
109131 {
110132 var match = input . Slice ( valueMatch . Index , valueMatch . Length ) ;
111- var includeIndex = match . IndexOf ( groupPrefix , StringComparison . InvariantCultureIgnoreCase ) ;
133+ var includeIndex = match . IndexOf ( groupPrefix , StringComparison . OrdinalIgnoreCase ) ;
112134 if ( includeIndex == - 1 )
113135 {
114136 return string . Empty ;
@@ -119,22 +141,15 @@ private static string GetGroup(ReadOnlySpan<char> input, ValueMatch valueMatch,
119141 var quoteIndex1 = match . IndexOf ( "\" " ) ;
120142 var quoteIndex2 = match . Slice ( quoteIndex1 + 1 ) . IndexOf ( "\" " ) ;
121143
122- var result = match . Slice ( quoteIndex1 + 1 , quoteIndex2 ) . ToString ( ) ;
123-
124- if ( toLower )
125- {
126- result = result . ToLowerInvariant ( ) ;
127- }
128-
129- return result ;
144+ return match . Slice ( quoteIndex1 + 1 , quoteIndex2 ) . ToString ( ) ;
130145 }
131146
132147 private static bool IsGroupMatch ( ReadOnlySpan < char > line , Regex regex , string groupPrefix , string value )
133148 {
134149 foreach ( var valueMatch in regex . EnumerateMatches ( line ) )
135150 {
136151 // We can't get the group from the ValueMatch, so doing it manually:
137- if ( GetGroup ( line , valueMatch , groupPrefix , toLower : true ) == value . ToLowerInvariant ( ) )
152+ if ( string . Equals ( GetGroup ( line , valueMatch , groupPrefix ) , value , StringComparison . OrdinalIgnoreCase ) )
138153 {
139154 return true ;
140155 }
@@ -150,12 +165,11 @@ private void DoInitialize()
150165 {
151166 foreach ( ReadOnlySpan < char > line in unsafeFileReader . ReadLines ( file ) )
152167 {
153-
154168 // Find all the packages.
155169 foreach ( var valueMatch in PackageReference ( ) . EnumerateMatches ( line ) )
156170 {
157171 // We can't get the group from the ValueMatch, so doing it manually:
158- var packageName = GetGroup ( line , valueMatch , "Include" , toLower : true ) ;
172+ var packageName = GetGroup ( line , valueMatch , "Include" ) . ToLowerInvariant ( ) ;
159173 if ( ! string . IsNullOrEmpty ( packageName ) )
160174 {
161175 allPackages . Add ( packageName ) ;
@@ -167,16 +181,23 @@ private void DoInitialize()
167181 || IsGroupMatch ( line , ProjectSdk ( ) , "Sdk" , "Microsoft.NET.Sdk.Web" )
168182 || IsGroupMatch ( line , FrameworkReference ( ) , "Include" , "Microsoft.AspNetCore.App" ) ;
169183
170-
171184 // Determine if implicit usings are used.
172185 useImplicitUsings = useImplicitUsings
173- || line . Contains ( "<ImplicitUsings>enable</ImplicitUsings>" . AsSpan ( ) , StringComparison . Ordinal )
174- || line . Contains ( "<ImplicitUsings>true</ImplicitUsings>" . AsSpan ( ) , StringComparison . Ordinal ) ;
186+ || line . Contains ( "<ImplicitUsings>enable</ImplicitUsings>" . AsSpan ( ) , StringComparison . OrdinalIgnoreCase )
187+ || line . Contains ( "<ImplicitUsings>true</ImplicitUsings>" . AsSpan ( ) , StringComparison . OrdinalIgnoreCase ) ;
188+
189+ // Determine if WPF is used.
190+ useWpf = useWpf
191+ || line . Contains ( "<UseWPF>true</UseWPF>" . AsSpan ( ) , StringComparison . OrdinalIgnoreCase ) ;
192+
193+ // Determine if Windows Forms is used.
194+ useWindowsForms = useWindowsForms
195+ || line . Contains ( "<UseWindowsForms>true</UseWindowsForms>" . AsSpan ( ) , StringComparison . OrdinalIgnoreCase ) ;
175196
176197 // Find all custom implicit usings.
177198 foreach ( var valueMatch in CustomImplicitUsingDeclarations ( ) . EnumerateMatches ( line ) )
178199 {
179- var ns = GetGroup ( line , valueMatch , "Include" , toLower : false ) ;
200+ var ns = GetGroup ( line , valueMatch , "Include" ) ;
180201 if ( ! string . IsNullOrEmpty ( ns ) )
181202 {
182203 implicitUsingNamespaces . Add ( ns ) ;
0 commit comments