@@ -36,71 +36,16 @@ public static string EscapeIdentifier(string identifier)
3636 : $ "@{ identifier } ";
3737 }
3838
39- public static ProjectItem ? ComputeProjectItem ( ( AdditionalText , AnalyzerConfigOptionsProvider ) tuple , CancellationToken cancellationToken )
39+ public static ProjectItem ? ComputeProjectItem ( ( AdditionalText additionalText , AnalyzerConfigOptionsProvider optionsProvider ) tuple , CancellationToken cancellationToken )
4040 {
41- var ( additionalText , optionsProvider ) = tuple ;
42- var fileOptions = optionsProvider . GetOptions ( additionalText ) ;
43- if ( ! fileOptions . TryGetValue ( "build_metadata.additionalfiles.GenKind" , out string ? kind ) || kind is null )
41+ if ( cancellationToken . IsCancellationRequested )
4442 return null ;
4543
46- fileOptions . TryGetValue ( "build_metadata.additionalfiles.TargetPath" , out var targetPath ) ;
47- fileOptions . TryGetValue ( "build_metadata.additionalfiles.ManifestResourceName" , out var manifestResourceName ) ;
48- fileOptions . TryGetValue ( "build_metadata.additionalfiles.RelativePath" , out var relativePath ) ;
49- fileOptions . TryGetValue ( "build_property.targetframework" , out var targetFramework ) ;
50- fileOptions . TryGetValue ( "build_property.Configuration" , out var configuration ) ;
51-
52- bool enableDiagnostics = false ;
53- if ( fileOptions . TryGetValue ( "build_property.EnableMauiXamlDiagnostics" , out var enDiag ) && string . Compare ( enDiag , "true" , StringComparison . OrdinalIgnoreCase ) == 0 )
54- enableDiagnostics = true ;
55- if ( fileOptions . TryGetValue ( "build_property.additionalfiles.EnableDiagnostics" , out enDiag ) && string . Compare ( enDiag , "true" , StringComparison . OrdinalIgnoreCase ) == 0 )
56- enableDiagnostics = true ;
57- if ( fileOptions . TryGetValue ( "build_property.additionalfiles.EnableDiagnostics" , out enDiag ) && string . Compare ( enDiag , "false" , StringComparison . OrdinalIgnoreCase ) == 0 )
58- enableDiagnostics = false ;
59-
60- var xamlinflator = 0 ;
61- if ( fileOptions . TryGetValue ( "build_metadata.additionalfiles.Inflator" , out var inflator ) && ! string . IsNullOrEmpty ( inflator ) )
62- {
63- var parts = inflator ! . Split ( ',' ) ;
64- for ( int i = 0 ; i < parts . Length ; i ++ )
65- {
66- var trimmed = parts [ i ] . Trim ( ) ;
67- if ( ! Enum . TryParse < XamlInflator > ( trimmed , true , out var xinfl ) )
68- throw new InvalidOperationException ( $ "Invalid inflator '{ trimmed } ' for { additionalText . Path } .") ;
69- xamlinflator |= ( int ) xinfl ;
70- }
71- }
72-
73- var enableLineInfo = true ;
74- if ( fileOptions . TryGetValue ( "build_property.MauiXamlLineInfo" , out var lineInfo ) && string . Compare ( lineInfo , "disable" , StringComparison . OrdinalIgnoreCase ) == 0 )
75- enableLineInfo = false ;
76- if ( fileOptions . TryGetValue ( "build_metadata.additionalfiles.LineInfo" , out lineInfo ) && string . Compare ( lineInfo , "enable" , StringComparison . OrdinalIgnoreCase ) == 0 )
77- enableLineInfo = true ;
78- if ( fileOptions . TryGetValue ( "build_metadata.additionalfiles.LineInfo" , out lineInfo ) && string . Compare ( lineInfo , "disable" , StringComparison . OrdinalIgnoreCase ) == 0 )
79- enableLineInfo = false ;
80-
81- string noWarn = "" ;
82- if ( fileOptions . TryGetValue ( "build_property.MauiXamlNoWarn" , out var noWarnValue ) )
83- noWarn = noWarnValue ;
84- if ( fileOptions . TryGetValue ( "build_metadata.additionalfiles.NoWarn" , out noWarnValue ) )
85- noWarn = noWarnValue ;
86-
87- return new ProjectItem
88- {
89- AdditionalText = additionalText ,
90- TargetPath = targetPath ,
91- RelativePath = relativePath ,
92- ManifestResourceName = manifestResourceName ,
93- Kind = kind ,
94- Inflator = ( XamlInflator ) xamlinflator ,
95- EnableLineInfo = enableLineInfo ,
96- EnableDiagnostics = enableDiagnostics ,
97- NoWarn = noWarn ,
98- TargetFramework = targetFramework ,
99- Configuration = configuration ! ,
100- } ;
44+ var projectItem = new ProjectItem ( tuple . additionalText , tuple . optionsProvider . GetOptions ( tuple . additionalText ) ) ;
45+ return projectItem . Kind == "None" ? null : projectItem ;
10146 }
10247
103- public static XamlProjectItemForIC ? ComputeXamlProjectItemForIC ( ( ProjectItem ? , AssemblyCaches ) itemAdnCaches , CancellationToken cancellationToken )
48+ public static XamlProjectItemForIC ? ComputeXamlProjectItemForIC ( ( ProjectItem ? , AssemblyCaches ) itemAdnCaches , CancellationToken cancellationToken )
10449 {
10550 var ( projectItem , assemblyCaches ) = itemAdnCaches ;
10651 var text = projectItem ? . AdditionalText . GetText ( cancellationToken ) ;
0 commit comments