@@ -97,7 +97,7 @@ internal sealed override CommandLineArguments CommonParse(IEnumerable<string> ar
97
97
bool ? delaySignSetting = null ;
98
98
string ? keyFileSetting = null ;
99
99
string ? keyContainerSetting = null ;
100
- List < ResourceDescription > managedResources = new List < ResourceDescription > ( ) ;
100
+ List < CommandLineResource > managedResources = new List < CommandLineResource > ( ) ;
101
101
List < CommandLineSourceFile > sourceFiles = new List < CommandLineSourceFile > ( ) ;
102
102
List < CommandLineSourceFile > additionalFiles = new List < CommandLineSourceFile > ( ) ;
103
103
var analyzerConfigPaths = ArrayBuilder < string > . GetInstance ( ) ;
@@ -742,8 +742,7 @@ internal sealed override CommandLineArguments CommonParse(IEnumerable<string> ar
742
742
break ; // Dev11 reports unrecognized option
743
743
}
744
744
745
- var embeddedResource = ParseResourceDescription ( arg , valueMemory . Value , baseDirectory , diagnostics , embedded : true ) ;
746
- if ( embeddedResource != null )
745
+ if ( TryParseResourceDescription ( arg , valueMemory . Value , baseDirectory , diagnostics , isEmbedded : true , out var embeddedResource ) )
747
746
{
748
747
managedResources . Add ( embeddedResource ) ;
749
748
resourcesOrModulesSpecified = true ;
@@ -758,8 +757,7 @@ internal sealed override CommandLineArguments CommonParse(IEnumerable<string> ar
758
757
break ; // Dev11 reports unrecognized option
759
758
}
760
759
761
- var linkedResource = ParseResourceDescription ( arg , valueMemory . Value , baseDirectory , diagnostics , embedded : false ) ;
762
- if ( linkedResource != null )
760
+ if ( TryParseResourceDescription ( arg , valueMemory . Value , baseDirectory , diagnostics , isEmbedded : false , out var linkedResource ) )
763
761
{
764
762
managedResources . Add ( linkedResource ) ;
765
763
resourcesOrModulesSpecified = true ;
@@ -1580,7 +1578,7 @@ internal sealed override CommandLineArguments CommonParse(IEnumerable<string> ar
1580
1578
DisplayHelp = displayHelp ,
1581
1579
DisplayVersion = displayVersion ,
1582
1580
DisplayLangVersions = displayLangVersions ,
1583
- ManifestResources = managedResources . AsImmutable ( ) ,
1581
+ ManifestResourceArguments = managedResources . AsImmutable ( ) ,
1584
1582
CompilationOptions = options ,
1585
1583
ParseOptions = parseOptions ,
1586
1584
EmitOptions = emitOptions ,
@@ -2015,78 +2013,51 @@ private static IEnumerable<InstrumentationKind> ParseInstrumentationKinds(string
2015
2013
}
2016
2014
}
2017
2015
2018
- internal static ResourceDescription ? ParseResourceDescription (
2019
- string arg ,
2020
- string resourceDescriptor ,
2021
- string ? baseDirectory ,
2022
- IList < Diagnostic > diagnostics ,
2023
- bool embedded ) =>
2024
- ParseResourceDescription ( arg , resourceDescriptor . AsMemory ( ) , baseDirectory , diagnostics , embedded ) ;
2025
-
2026
- internal static ResourceDescription ? ParseResourceDescription (
2027
- string arg ,
2016
+ internal static bool TryParseResourceDescription (
2017
+ string argName ,
2028
2018
ReadOnlyMemory < char > resourceDescriptor ,
2029
2019
string ? baseDirectory ,
2030
2020
IList < Diagnostic > diagnostics ,
2031
- bool embedded )
2021
+ bool isEmbedded ,
2022
+ out CommandLineResource resource )
2032
2023
{
2033
- string ? filePath ;
2034
- string ? fullPath ;
2035
- string ? fileName ;
2036
- string ? resourceName ;
2037
- string ? accessibility ;
2038
-
2039
- ParseResourceDescription (
2024
+ if ( ! TryParseResourceDescription (
2040
2025
resourceDescriptor ,
2041
2026
baseDirectory ,
2042
- false ,
2043
- out filePath ,
2044
- out fullPath ,
2045
- out fileName ,
2046
- out resourceName ,
2047
- out accessibility ) ;
2048
-
2049
- bool isPublic ;
2050
- if ( accessibility == null )
2051
- {
2052
- // If no accessibility is given, we default to "public".
2053
- // NOTE: Dev10 distinguishes between null and empty/whitespace-only.
2054
- isPublic = true ;
2055
- }
2056
- else if ( string . Equals ( accessibility , "public" , StringComparison . OrdinalIgnoreCase ) )
2027
+ skipLeadingSeparators : false ,
2028
+ allowEmptyAccessibility : false ,
2029
+ out var filePath ,
2030
+ out var fullPath ,
2031
+ out var fileName ,
2032
+ out var resourceName ,
2033
+ out var isPublic ,
2034
+ out var rawAccessibility ) )
2057
2035
{
2058
- isPublic = true ;
2059
- }
2060
- else if ( string . Equals ( accessibility , "private" , StringComparison . OrdinalIgnoreCase ) )
2061
- {
2062
- isPublic = false ;
2063
- }
2064
- else
2065
- {
2066
- AddDiagnostic ( diagnostics , ErrorCode . ERR_BadResourceVis , accessibility ) ;
2067
- return null ;
2068
- }
2036
+ if ( isPublic == null )
2037
+ {
2038
+ AddDiagnostic ( diagnostics , ErrorCode . ERR_BadResourceVis , rawAccessibility ?? "" ) ;
2039
+ }
2040
+ else if ( RoslynString . IsNullOrWhiteSpace ( filePath ) )
2041
+ {
2042
+ AddDiagnostic ( diagnostics , ErrorCode . ERR_NoFileSpec , argName ) ;
2043
+ }
2044
+ else
2045
+ {
2046
+ Debug . Assert ( ! PathUtilities . IsValidFilePath ( fullPath ) ) ;
2047
+ AddDiagnostic ( diagnostics , ErrorCode . FTL_InvalidInputFileName , filePath ) ;
2048
+ }
2069
2049
2070
- if ( RoslynString . IsNullOrWhiteSpace ( filePath ) )
2071
- {
2072
- AddDiagnostic ( diagnostics , ErrorCode . ERR_NoFileSpec , arg ) ;
2073
- return null ;
2050
+ resource = default ;
2051
+ return false ;
2074
2052
}
2075
- Debug . Assert ( ! resourceName . IsEmpty ( ) ) ; // see ParseResourceDescription's check on filePath
2076
2053
2077
- if ( ! PathUtilities . IsValidFilePath ( fullPath ) )
2078
- {
2079
- AddDiagnostic ( diagnostics , ErrorCode . FTL_InvalidInputFileName , filePath ) ;
2080
- return null ;
2081
- }
2054
+ resource = new CommandLineResource (
2055
+ resourceName : resourceName ,
2056
+ fullPath : fullPath ,
2057
+ linkedResourceFileName : isEmbedded ? null : fileName ,
2058
+ isPublic . Value ) ;
2082
2059
2083
- Func < Stream > dataProvider = ( ) =>
2084
- {
2085
- // Use FileShare.ReadWrite because the file could be opened by the current process.
2086
- // For example, it is an XML doc file produced by the build.
2087
- return new FileStream ( fullPath , FileMode . Open , FileAccess . Read , FileShare . ReadWrite ) ;
2088
- } ;
2089
- return new ResourceDescription ( resourceName , fileName , dataProvider , isPublic , embedded , checkArgs : false ) ;
2060
+ return true ;
2090
2061
}
2091
2062
2092
2063
private static void ParseWarnings ( ReadOnlyMemory < char > value , ArrayBuilder < string > ids )
0 commit comments