internal override void ValidateOptions(ArrayBuilder <Diagnostic> builder) { ValidateOptions(builder, MessageProvider.Instance); // Validate LanguageVersion not SpecifiedLanguageVersion, after Latest/Default has been converted: if (!LanguageVersion.IsValid()) { builder.Add(Diagnostic.Create(MessageProvider.Instance, (int)ErrorCode.ERR_BadLanguageVersion, LanguageVersion.ToString())); } if (!PreprocessorSymbols.IsDefaultOrEmpty) { foreach (var symbol in PreprocessorSymbols) { if (symbol == null) { builder.Add(Diagnostic.Create(MessageProvider.Instance, (int)ErrorCode.ERR_InvalidPreprocessingSymbol, "null")); } else if (!SyntaxFacts.IsValidIdentifier(symbol)) { builder.Add(Diagnostic.Create(MessageProvider.Instance, (int)ErrorCode.ERR_InvalidPreprocessingSymbol, symbol)); } } } }
public CSharpParseOptions( LanguageVersion languageVersion = LanguageVersion.CSharp6, DocumentationMode documentationMode = DocumentationMode.Parse, SourceCodeKind kind = SourceCodeKind.Regular, IEnumerable <string> preprocessorSymbols = null) : this(languageVersion, documentationMode, kind, preprocessorSymbols.ToImmutableArrayOrEmpty()) { if (!languageVersion.IsValid()) { throw new ArgumentOutOfRangeException(nameof(languageVersion)); } if (!kind.IsValid()) { throw new ArgumentOutOfRangeException(nameof(kind)); } if (preprocessorSymbols != null) { foreach (var preprocessorSymbol in preprocessorSymbols) { if (!SyntaxFacts.IsValidIdentifier(preprocessorSymbol)) { throw new ArgumentException("preprocessorSymbols"); } } } }
public CSharpParseOptions( LanguageVersion languageVersion = LanguageVersion.Default, DocumentationMode documentationMode = DocumentationMode.Parse, SourceCodeKind kind = SourceCodeKind.Regular, IEnumerable <string> preprocessorSymbols = null) : this(languageVersion, documentationMode, kind, preprocessorSymbols.ToImmutableArrayOrEmpty(), ImmutableDictionary <string, string> .Empty) { // We test the mapped value, LanguageVersion, rather than the parameter, languageVersion, // which has not had "Latest" mapped to the latest version yet. if (!LanguageVersion.IsValid()) { throw new ArgumentOutOfRangeException(nameof(languageVersion)); } if (!kind.IsValid()) { throw new ArgumentOutOfRangeException(nameof(kind)); } if (preprocessorSymbols != null) { foreach (var preprocessorSymbol in preprocessorSymbols) { if (!SyntaxFacts.IsValidIdentifier(preprocessorSymbol)) { throw new ArgumentException(nameof(preprocessorSymbol)); } } } }
public CSharpParseOptions( LanguageVersion languageVersion = LanguageVersion.CSharp6, DocumentationMode documentationMode = DocumentationMode.Parse, SourceCodeKind kind = SourceCodeKind.Regular, ImmutableArray <string> preprocessorSymbols = default(ImmutableArray <string>)) : this(languageVersion, documentationMode, kind, preprocessorSymbols.NullToEmpty(), privateCtor : true) { if (!languageVersion.IsValid()) { throw new ArgumentOutOfRangeException("languageVersion"); } if (!kind.IsValid()) { throw new ArgumentOutOfRangeException("kind"); } if (!preprocessorSymbols.IsDefaultOrEmpty) { foreach (var preprocessorSymbol in preprocessorSymbols) { if (!SyntaxKindFacts.IsValidIdentifier(preprocessorSymbol)) { throw new ArgumentException("preprocessorSymbols"); } } } }
//warnaserror[+|-] //warnaserror[+|-]:<warn list> //unsafe[+|-] //warn:<n> //nowarn:<warn list> public ParseOptions( CompatibilityMode compatibility = CompatibilityMode.None, LanguageVersion languageVersion = CSharp.LanguageVersion.CSharp4, IEnumerable <string> preprocessorSymbols = null, bool suppressDocumentationCommentParse = false, SourceCodeKind kind = SourceCodeKind.Regular) { if (!compatibility.IsValid()) { throw new ArgumentOutOfRangeException("compatibility"); } if (!languageVersion.IsValid()) { throw new ArgumentOutOfRangeException("languageVersion"); } if (!kind.IsValid()) { throw new ArgumentOutOfRangeException("kind"); } this.Compatibility = compatibility; this.LanguageVersion = languageVersion; this.PreprocessorSymbols = preprocessorSymbols.AsReadOnlyOrEmpty(); this.SuppressDocumentationCommentParse = suppressDocumentationCommentParse; this.Kind = kind; }
public override void ValidateOptions(ArrayBuilder <Diagnostic> builder) { base.ValidateOptions(builder); // Validate LanguageVersion not SpecifiedLanguageVersion, after Latest/Default has been converted: if (!LanguageVersion.IsValid()) { builder.Add(MetaErrorCode.ERR_BadLanguageVersion.ToDiagnosticWithNoLocation(LanguageVersion.ToString())); } }
public SoalParseOptions WithLanguageVersion(LanguageVersion version) { if (version == this.LanguageVersion) { return(this); } if (!version.IsValid()) { throw new ArgumentOutOfRangeException(nameof(version)); } return(new SoalParseOptions(this) { LanguageVersion = version }); }
public SoalParseOptions( LanguageVersion languageVersion = LanguageVersion.Soal1, DocumentationMode documentationMode = DocumentationMode.Parse, SourceCodeKind kind = SourceCodeKind.Regular) : base(kind, documentationMode) { if (!languageVersion.IsValid()) { throw new ArgumentOutOfRangeException(nameof(languageVersion)); } if (!kind.IsValid()) { throw new ArgumentOutOfRangeException(nameof(kind)); } this.LanguageVersion = languageVersion; _features = ImmutableDictionary <string, string> .Empty; }
/// <summary> /// Parse a LanguageVersion from a string input, as the command-line compiler does. /// </summary> public static bool TryParse(this string version, out LanguageVersion result) { if (version == null) { result = LanguageVersion.Default; return(true); } switch (version.ToLowerInvariant()) { case "iso-1": result = LanguageVersion.CSharp1; return(true); case "iso-2": result = LanguageVersion.CSharp2; return(true); case "default": result = LanguageVersion.Default; return(true); case "latest": result = LanguageVersion.Latest; return(true); case "7.1": result = LanguageVersion.CSharp7_1; return(true); default: if (int.TryParse(version, NumberStyles.None, CultureInfo.InvariantCulture, out int versionNumber) && versionNumber <= 7) { result = (LanguageVersion)versionNumber; if (result.IsValid()) { return(true); } } result = LanguageVersion.Default; return(false); } }
public CSharpParseOptions WithLanguageVersion(LanguageVersion version) { version = version.MapLatestToVersion(); if (version == this.LanguageVersion) { return(this); } if (!version.IsValid()) { throw new ArgumentOutOfRangeException(nameof(version)); } return(new CSharpParseOptions(this) { LanguageVersion = version }); }
public CSharpParseOptions WithLanguageVersion(LanguageVersion version) { if (version == this.LanguageVersion) { return(this); } if (!version.IsValid()) { throw new ArgumentOutOfRangeException("version"); } return(new CSharpParseOptions( version, this.DocumentationMode, this.Kind, this.PreprocessorSymbols, privateCtor: true )); }
//warnaserror[+|-] //warnaserror[+|-]:<warn list> //unsafe[+|-] //warn:<n> //nowarn:<warn list> public ParseOptions( CompatibilityMode compatibility = CompatibilityMode.None, LanguageVersion languageVersion = CSharp.LanguageVersion.CSharp4, IEnumerable<string> preprocessorSymbols = null, bool suppressDocumentationCommentParse = false, SourceCodeKind kind = SourceCodeKind.Regular) { if (!compatibility.IsValid()) { throw new ArgumentOutOfRangeException("compatibility"); } if (!languageVersion.IsValid()) { throw new ArgumentOutOfRangeException("languageVersion"); } if (!kind.IsValid()) { throw new ArgumentOutOfRangeException("kind"); } this.Compatibility = compatibility; this.LanguageVersion = languageVersion; this.PreprocessorSymbols = preprocessorSymbols.AsReadOnlyOrEmpty(); this.SuppressDocumentationCommentParse = suppressDocumentationCommentParse; this.Kind = kind; }