@@ -61,6 +61,28 @@ public bool UseImplicitUsings
61
61
}
62
62
}
63
63
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
+
64
86
private bool isLegacyProjectStructureUsed = false ;
65
87
66
88
public bool IsLegacyProjectStructureUsed
@@ -105,10 +127,10 @@ internal FileContent(ILogger logger,
105
127
public FileContent ( ILogger logger , IEnumerable < string > files ) : this ( logger , files , new UnsafeFileReader ( ) )
106
128
{ }
107
129
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 )
109
131
{
110
132
var match = input . Slice ( valueMatch . Index , valueMatch . Length ) ;
111
- var includeIndex = match . IndexOf ( groupPrefix , StringComparison . InvariantCultureIgnoreCase ) ;
133
+ var includeIndex = match . IndexOf ( groupPrefix , StringComparison . OrdinalIgnoreCase ) ;
112
134
if ( includeIndex == - 1 )
113
135
{
114
136
return string . Empty ;
@@ -119,22 +141,15 @@ private static string GetGroup(ReadOnlySpan<char> input, ValueMatch valueMatch,
119
141
var quoteIndex1 = match . IndexOf ( "\" " ) ;
120
142
var quoteIndex2 = match . Slice ( quoteIndex1 + 1 ) . IndexOf ( "\" " ) ;
121
143
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 ( ) ;
130
145
}
131
146
132
147
private static bool IsGroupMatch ( ReadOnlySpan < char > line , Regex regex , string groupPrefix , string value )
133
148
{
134
149
foreach ( var valueMatch in regex . EnumerateMatches ( line ) )
135
150
{
136
151
// 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 ) )
138
153
{
139
154
return true ;
140
155
}
@@ -150,12 +165,11 @@ private void DoInitialize()
150
165
{
151
166
foreach ( ReadOnlySpan < char > line in unsafeFileReader . ReadLines ( file ) )
152
167
{
153
-
154
168
// Find all the packages.
155
169
foreach ( var valueMatch in PackageReference ( ) . EnumerateMatches ( line ) )
156
170
{
157
171
// 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 ( ) ;
159
173
if ( ! string . IsNullOrEmpty ( packageName ) )
160
174
{
161
175
allPackages . Add ( packageName ) ;
@@ -167,16 +181,23 @@ private void DoInitialize()
167
181
|| IsGroupMatch ( line , ProjectSdk ( ) , "Sdk" , "Microsoft.NET.Sdk.Web" )
168
182
|| IsGroupMatch ( line , FrameworkReference ( ) , "Include" , "Microsoft.AspNetCore.App" ) ;
169
183
170
-
171
184
// Determine if implicit usings are used.
172
185
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 ) ;
175
196
176
197
// Find all custom implicit usings.
177
198
foreach ( var valueMatch in CustomImplicitUsingDeclarations ( ) . EnumerateMatches ( line ) )
178
199
{
179
- var ns = GetGroup ( line , valueMatch , "Include" , toLower : false ) ;
200
+ var ns = GetGroup ( line , valueMatch , "Include" ) ;
180
201
if ( ! string . IsNullOrEmpty ( ns ) )
181
202
{
182
203
implicitUsingNamespaces . Add ( ns ) ;
0 commit comments