internal override void ValidateOptions(ArrayBuilder <Diagnostic> builder) { ValidateOptions(builder, MessageProvider.Instance); // /main & /target:{library|netmodule|winmdobj} if (this.MainTypeName != null) { if (this.OutputKind.IsValid() && !this.OutputKind.IsApplication()) { builder.Add(Diagnostic.Create(MessageProvider.Instance, (int)ErrorCode.ERR_NoMainOnDLL)); } if (!MainTypeName.IsValidClrTypeName()) { builder.Add(Diagnostic.Create(MessageProvider.Instance, (int)ErrorCode.ERR_BadCompilationOptionValue, nameof(MainTypeName), MainTypeName)); } } if (!Platform.IsValid()) { builder.Add(Diagnostic.Create(MessageProvider.Instance, (int)ErrorCode.ERR_BadPlatformType, Platform.ToString())); } if (ModuleName != null) { MetadataHelpers.CheckAssemblyOrModuleName(ModuleName, MessageProvider.Instance, (int)ErrorCode.ERR_BadModuleName, builder); } if (!OutputKind.IsValid()) { builder.Add(Diagnostic.Create(MessageProvider.Instance, (int)ErrorCode.ERR_BadCompilationOptionValue, nameof(OutputKind), OutputKind.ToString())); } if (!OptimizationLevel.IsValid()) { builder.Add(Diagnostic.Create(MessageProvider.Instance, (int)ErrorCode.ERR_BadCompilationOptionValue, nameof(OptimizationLevel), OptimizationLevel.ToString())); } if (ScriptClassName == null || !ScriptClassName.IsValidClrTypeName()) { builder.Add(Diagnostic.Create(MessageProvider.Instance, (int)ErrorCode.ERR_BadCompilationOptionValue, nameof(ScriptClassName), ScriptClassName ?? "null")); } if (WarningLevel < 0) { builder.Add(Diagnostic.Create(MessageProvider.Instance, (int)ErrorCode.ERR_BadCompilationOptionValue, nameof(WarningLevel), WarningLevel)); } if (Usings != null && Usings.Any(static u => !u.IsValidClrNamespaceName()))
internal override void ValidateOptions(ArrayBuilder <Diagnostic> builder) { ValidateOptions(builder, MessageProvider.Instance); // /main & /target:{library|netmodule|winmdobj} if (this.MainTypeName != null) { if (this.OutputKind.IsValid() && !this.OutputKind.IsApplication()) { builder.Add(Diagnostic.Create(MessageProvider.Instance, (int)ErrorCode.ERR_NoMainOnDLL)); } if (!MainTypeName.IsValidClrTypeName()) { builder.Add(Diagnostic.Create(MessageProvider.Instance, (int)ErrorCode.ERR_BadCompilationOptionValue, nameof(MainTypeName), MainTypeName)); } } if (!Platform.IsValid()) { builder.Add(Diagnostic.Create(MessageProvider.Instance, (int)ErrorCode.ERR_BadPlatformType, Platform.ToString())); } if (ModuleName != null) { MetadataHelpers.CheckAssemblyOrModuleName(ModuleName, MessageProvider.Instance, (int)ErrorCode.ERR_BadModuleName, builder); } if (!OutputKind.IsValid()) { builder.Add(Diagnostic.Create(MessageProvider.Instance, (int)ErrorCode.ERR_BadCompilationOptionValue, nameof(OutputKind), OutputKind.ToString())); } if (!OptimizationLevel.IsValid()) { builder.Add(Diagnostic.Create(MessageProvider.Instance, (int)ErrorCode.ERR_BadCompilationOptionValue, nameof(OptimizationLevel), OptimizationLevel.ToString())); } if (ScriptClassName == null || !ScriptClassName.IsValidClrTypeName()) { builder.Add(Diagnostic.Create(MessageProvider.Instance, (int)ErrorCode.ERR_BadCompilationOptionValue, nameof(ScriptClassName), ScriptClassName ?? "null")); } if (WarningLevel < 0 || WarningLevel > 4) { builder.Add(Diagnostic.Create(MessageProvider.Instance, (int)ErrorCode.ERR_BadCompilationOptionValue, nameof(WarningLevel), WarningLevel)); } if (Usings != null && Usings.Any(u => !u.IsValidClrNamespaceName())) { builder.Add(Diagnostic.Create(MessageProvider.Instance, (int)ErrorCode.ERR_BadCompilationOptionValue, nameof(Usings), Usings.Where(u => !u.IsValidClrNamespaceName()).First() ?? "null")); } if (Platform == Platform.AnyCpu32BitPreferred && OutputKind.IsValid() && !(OutputKind == OutputKind.ConsoleApplication || OutputKind == OutputKind.WindowsApplication || OutputKind == OutputKind.WindowsRuntimeApplication)) { builder.Add(Diagnostic.Create(MessageProvider.Instance, (int)ErrorCode.ERR_BadPrefer32OnLib)); } if (!MetadataImportOptions.IsValid()) { builder.Add(Diagnostic.Create(MessageProvider.Instance, (int)ErrorCode.ERR_BadCompilationOptionValue, nameof(MetadataImportOptions), MetadataImportOptions.ToString())); } // TODO: add check for // (kind == 'arm' || kind == 'appcontainer' || kind == 'winmdobj') && // (version >= "6.2") }
internal override void ValidateOptions(ArrayBuilder <Diagnostic> builder) { // /main & /target:{library|netmodule|winmdobj} if (this.MainTypeName != null) { if (this.OutputKind.IsValid() && !this.OutputKind.IsApplication()) { builder.Add(Diagnostic.Create(MessageProvider.Instance, (int)ErrorCode.ERR_NoMainOnDLL)); } if (!MainTypeName.IsValidClrTypeName()) { builder.Add(Diagnostic.Create(MessageProvider.Instance, (int)ErrorCode.ERR_BadCompilationOptionValue, "MainTypeName", MainTypeName)); } } if (FileAlignment != 0 && !IsValidFileAlignment(FileAlignment)) { builder.Add(Diagnostic.Create(MessageProvider.Instance, (int)ErrorCode.ERR_BadFileAlignment, FileAlignment)); } if (!Platform.IsValid()) { builder.Add(Diagnostic.Create(MessageProvider.Instance, (int)ErrorCode.ERR_BadPlatformType, Platform.ToString())); } if (ModuleName != null) { Exception e = MetadataHelpers.CheckAssemblyOrModuleName(ModuleName, "ModuleName"); if (e != null) { builder.Add(Diagnostic.Create(MessageProvider.Instance, (int)ErrorCode.ERR_BadCompilationOption, e.Message)); } } if (!OutputKind.IsValid()) { builder.Add(Diagnostic.Create(MessageProvider.Instance, (int)ErrorCode.ERR_BadCompilationOptionValue, "OutputKind", OutputKind.ToString())); } if (!OptimizationLevel.IsValid()) { builder.Add(Diagnostic.Create(MessageProvider.Instance, (int)ErrorCode.ERR_BadCompilationOptionValue, "OptimizationLevel", OptimizationLevel.ToString())); } if (!SubsystemVersion.Equals(SubsystemVersion.None) && !SubsystemVersion.IsValid) { builder.Add(Diagnostic.Create(MessageProvider.Instance, (int)ErrorCode.ERR_BadSubsystemVersion, SubsystemVersion.ToString())); } if (ScriptClassName == null || !ScriptClassName.IsValidClrTypeName()) { builder.Add(Diagnostic.Create(MessageProvider.Instance, (int)ErrorCode.ERR_BadCompilationOptionValue, "ScriptClassName", ScriptClassName ?? "null")); } if (WarningLevel < 0 || WarningLevel > 4) { builder.Add(Diagnostic.Create(MessageProvider.Instance, (int)ErrorCode.ERR_BadCompilationOptionValue, "WarningLevel", WarningLevel)); } if (Usings != null && Usings.Any(u => !u.IsValidClrNamespaceName())) { builder.Add(Diagnostic.Create(MessageProvider.Instance, (int)ErrorCode.ERR_BadCompilationOptionValue, "Usings", Usings.Where(u => !u.IsValidClrNamespaceName()).First() ?? "null")); } if (Platform == Platform.AnyCpu32BitPreferred && OutputKind.IsValid() && !(OutputKind == OutputKind.ConsoleApplication || OutputKind == OutputKind.WindowsApplication || OutputKind == OutputKind.WindowsRuntimeApplication)) { builder.Add(Diagnostic.Create(MessageProvider.Instance, (int)ErrorCode.ERR_BadPrefer32OnLib)); } // TODO: add check for // (kind == 'arm' || kind == 'appcontainer' || kind == 'winmdobj') && // (version >= "6.2") }