@@ -50,8 +50,6 @@ internal void Generate(GeneratorExecutionContext context)
50
50
try
51
51
{
52
52
var validPlatform = PlatformHelper . IsValidPlatform ( context ) ;
53
- var isDesignTime = DesignTimeHelper . IsDesignTime ( context ) ;
54
- var isApplication = PlatformHelper . IsApplication ( context ) ;
55
53
56
54
if ( ! bool . TryParse ( context . GetMSBuildPropertyValue ( "UnoXamlResourcesTrimming" ) , out _xamlResourcesTrimming ) )
57
55
{
@@ -90,17 +88,15 @@ from module in sym.Modules
90
88
91
89
modules = modules . Concat ( context . Compilation . SourceModule ) ;
92
90
93
- var bindableTypes = from module in modules
94
- from type in module . GlobalNamespace . GetNamespaceTypes ( )
95
- where (
96
- type . GetAllInterfaces ( ) . Any ( i => SymbolEqualityComparer . Default . Equals ( i , _dependencyObjectSymbol ) )
97
- || additionalLinkerHintSymbols . Contains ( type )
98
- )
99
- select type ;
91
+ var propertyNames = ( from module in modules
92
+ from type in module . GlobalNamespace . GetNamespaceTypes ( )
93
+ where (
94
+ type . GetAllInterfaces ( ) . Any ( i => SymbolEqualityComparer . Default . Equals ( i , _dependencyObjectSymbol ) )
95
+ || additionalLinkerHintSymbols . Contains ( type )
96
+ )
97
+ select LinkerHintsHelpers . GetPropertyAvailableName ( type . GetFullMetadataName ( ) ) ) . ToArray ( ) ;
100
98
101
- bindableTypes = bindableTypes . ToArray ( ) ;
102
-
103
- context . AddSource ( "DependencyObjectAvailability" , GenerateTypeProviders ( bindableTypes ) ) ;
99
+ context . AddSource ( "DependencyObjectAvailability" , GenerateTypeProviders ( propertyNames ) ) ;
104
100
105
101
#if DEBUG
106
102
context . AddSource ( "DependencyObjectAvailability_Debug" ,
@@ -115,7 +111,7 @@ from type in module.GlobalNamespace.GetNamespaceTypes()
115
111
""" ) ;
116
112
#endif
117
113
118
- GenerateLinkerSubstitutionDefinition ( bindableTypes , isApplication ) ;
114
+ GenerateLinkerSubstitutionDefinition ( propertyNames ) ;
119
115
}
120
116
}
121
117
catch ( OperationCanceledException )
@@ -189,7 +185,7 @@ private HashSet<INamedTypeSymbol> FindAdditionalLinkerHints(GeneratorExecutionCo
189
185
return types ;
190
186
}
191
187
192
- private void GenerateLinkerSubstitutionDefinition ( IEnumerable < INamedTypeSymbol > bindableTypes , bool isApplication )
188
+ private void GenerateLinkerSubstitutionDefinition ( string [ ] propertyNames )
193
189
{
194
190
// <linker>
195
191
// <assembly fullname="Uno.UI">
@@ -221,10 +217,8 @@ private void GenerateLinkerSubstitutionDefinition(IEnumerable<INamedTypeSymbol>
221
217
typeNode . SetAttribute ( "fullname" , LinkerHintsHelpers . GetLinkerHintsClassName ( _defaultNamespace ) ) ;
222
218
assemblyNode . AppendChild ( typeNode ) ;
223
219
224
- foreach ( var type in bindableTypes )
220
+ foreach ( var propertyName in propertyNames )
225
221
{
226
- var propertyName = LinkerHintsHelpers . GetPropertyAvailableName ( type . GetFullMetadataName ( ) ) ;
227
-
228
222
var methodNode = doc . CreateElement ( string . Empty , "method" , string . Empty ) ;
229
223
methodNode . SetAttribute ( "signature" , $ "System.Boolean get_{ propertyName } ()") ;
230
224
methodNode . SetAttribute ( "body" , "stub" ) ;
@@ -240,7 +234,7 @@ private void GenerateLinkerSubstitutionDefinition(IEnumerable<INamedTypeSymbol>
240
234
doc . Save ( fileName ) ;
241
235
}
242
236
243
- private string GenerateTypeProviders ( IEnumerable < INamedTypeSymbol > bindableTypes )
237
+ private string GenerateTypeProviders ( string [ ] propertyNames )
244
238
{
245
239
var writer = new IndentedStringBuilder ( ) ;
246
240
@@ -252,9 +246,6 @@ private string GenerateTypeProviders(IEnumerable<INamedTypeSymbol> bindableTypes
252
246
writer . AppendLine ( ) ;
253
247
writer . AppendLineIndented ( "#pragma warning disable 618 // Ignore obsolete members warnings" ) ;
254
248
writer . AppendLineIndented ( "#pragma warning disable 1591 // Ignore missing XML comment warnings" ) ;
255
- writer . AppendLineIndented ( "using System;" ) ;
256
- writer . AppendLineIndented ( "using System.Linq;" ) ;
257
- writer . AppendLineIndented ( "using System.Diagnostics;" ) ;
258
249
259
250
writer . AppendLineIndented ( $ "// _intermediatePath: { _intermediatePath } ") ;
260
251
writer . AppendLineIndented ( $ "// _intermediateOutputPath: { _intermediateOutputPath } ") ;
@@ -263,11 +254,9 @@ private string GenerateTypeProviders(IEnumerable<INamedTypeSymbol> bindableTypes
263
254
{
264
255
using ( writer . BlockInvariant ( "internal class " + LinkerHintsHelpers . GetLinkerHintsClassName ( ) ) )
265
256
{
266
- foreach ( var type in bindableTypes )
257
+ foreach ( var propertyName in propertyNames )
267
258
{
268
- var safeTypeName = LinkerHintsHelpers . GetPropertyAvailableName ( type . GetFullMetadataName ( ) ) ;
269
-
270
- writer . AppendLineIndented ( $ "internal static bool { safeTypeName } => true;") ;
259
+ writer . AppendLineIndented ( $ "internal static bool { propertyName } => true;") ;
271
260
}
272
261
}
273
262
}
0 commit comments