internal void ValidateOptions(DiagnosticBag diagnostics, CommonMessageProvider messageProvider) { if (!DebugInformationFormat.IsValid()) { diagnostics.Add(messageProvider.CreateDiagnostic(messageProvider.ERR_InvalidDebugInformationFormat, Location.None, (int)DebugInformationFormat)); } if (OutputNameOverride != null) { Exception error = MetadataHelpers.CheckAssemblyOrModuleName(OutputNameOverride, argumentName: null); if (error != null) { diagnostics.Add(messageProvider.CreateDiagnostic(messageProvider.ERR_InvalidOutputName, Location.None, error.Message)); } } if (FileAlignment != 0 && !IsValidFileAlignment(FileAlignment)) { diagnostics.Add(messageProvider.CreateDiagnostic(messageProvider.ERR_InvalidFileAlignment, Location.None, FileAlignment)); } if (!SubsystemVersion.Equals(SubsystemVersion.None) && !SubsystemVersion.IsValid) { diagnostics.Add(messageProvider.CreateDiagnostic(messageProvider.ERR_InvalidSubsystemVersion, Location.None, SubsystemVersion.ToString())); } }
internal void ValidateOptions(DiagnosticBag diagnostics, CommonMessageProvider messageProvider) { if (!DebugInformationFormat.IsValid()) { diagnostics.Add(messageProvider.CreateDiagnostic(messageProvider.ERR_InvalidDebugInformationFormat, Location.None, (int)DebugInformationFormat)); } foreach (var instrumentationKind in InstrumentationKinds) { if (!instrumentationKind.IsValid()) { diagnostics.Add(messageProvider.CreateDiagnostic(messageProvider.ERR_InvalidInstrumentationKind, Location.None, (int)instrumentationKind)); } } if (OutputNameOverride != null) { MetadataHelpers.CheckAssemblyOrModuleName(OutputNameOverride, messageProvider, messageProvider.ERR_InvalidOutputName, diagnostics); } if (FileAlignment != 0 && !IsValidFileAlignment(FileAlignment)) { diagnostics.Add(messageProvider.CreateDiagnostic(messageProvider.ERR_InvalidFileAlignment, Location.None, FileAlignment)); } if (!SubsystemVersion.Equals(SubsystemVersion.None) && !SubsystemVersion.IsValid) { diagnostics.Add(messageProvider.CreateDiagnostic(messageProvider.ERR_InvalidSubsystemVersion, Location.None, SubsystemVersion.ToString())); } }
internal void ValidateOptions(DiagnosticBag diagnostics, CommonMessageProvider messageProvider, bool isDeterministic) { if (!DebugInformationFormat.IsValid()) { diagnostics.Add(messageProvider.CreateDiagnostic(messageProvider.ERR_InvalidDebugInformationFormat, Location.None, (int)DebugInformationFormat)); } foreach (var instrumentationKind in InstrumentationKinds) { if (!instrumentationKind.IsValid()) { diagnostics.Add(messageProvider.CreateDiagnostic(messageProvider.ERR_InvalidInstrumentationKind, Location.None, (int)instrumentationKind)); } } if (OutputNameOverride != null) { MetadataHelpers.CheckAssemblyOrModuleName(OutputNameOverride, messageProvider, messageProvider.ERR_InvalidOutputName, diagnostics); } if (FileAlignment != 0 && !IsValidFileAlignment(FileAlignment)) { diagnostics.Add(messageProvider.CreateDiagnostic(messageProvider.ERR_InvalidFileAlignment, Location.None, FileAlignment)); } if (!SubsystemVersion.Equals(SubsystemVersion.None) && !SubsystemVersion.IsValid) { diagnostics.Add(messageProvider.CreateDiagnostic(messageProvider.ERR_InvalidSubsystemVersion, Location.None, SubsystemVersion.ToString())); } if (PdbChecksumAlgorithm.Name != null) { try { IncrementalHash.CreateHash(PdbChecksumAlgorithm).Dispose(); } catch { diagnostics.Add(messageProvider.CreateDiagnostic(messageProvider.ERR_InvalidHashAlgorithmName, Location.None, PdbChecksumAlgorithm.ToString())); } } else if (isDeterministic) { diagnostics.Add(messageProvider.CreateDiagnostic(messageProvider.ERR_InvalidHashAlgorithmName, Location.None, "")); } if (PdbFilePath != null && !PathUtilities.IsValidFilePath(PdbFilePath)) { diagnostics.Add(messageProvider.CreateDiagnostic(messageProvider.FTL_InvalidInputFileName, Location.None, PdbFilePath)); } }
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)); } 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)); } if (!DebugInformationKind.IsValid()) { builder.Add(Diagnostic.Create(MessageProvider.Instance, (int)ErrorCode.ERR_BadCompilationOptionValue, "DebugInformationKind", DebugInformationKind)); } 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 (Features == null) { builder.Add(Diagnostic.Create(MessageProvider.Instance, (int)ErrorCode.ERR_BadCompilationOptionValue, "Features", "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") }