From 2b759bdac845be3e2ebc9a484525564f62b814ec Mon Sep 17 00:00:00 2001 From: AliveDevil Date: Thu, 25 Jul 2024 13:23:11 +0200 Subject: [PATCH 1/8] Handle MSBuild properties NoWarn, TreatWarningsAsErrors, WarningsAsErrors --- src/IKVM.NET.Sdk/targets/IKVM.Java.Core.NoTasks.targets | 3 +++ src/IKVM.NET.Sdk/targets/IKVM.Java.Core.Tasks.targets | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/IKVM.NET.Sdk/targets/IKVM.Java.Core.NoTasks.targets b/src/IKVM.NET.Sdk/targets/IKVM.Java.Core.NoTasks.targets index f937f4ab5..f6e455458 100644 --- a/src/IKVM.NET.Sdk/targets/IKVM.Java.Core.NoTasks.targets +++ b/src/IKVM.NET.Sdk/targets/IKVM.Java.Core.NoTasks.targets @@ -277,6 +277,9 @@ Value = b.ToString(); <_IkvmCompilerArgs Include="-nologo" /> <_IkvmCompilerArgs Include="-bootstrap" Condition=" '$(Bootstrap)' == 'true' " /> <_IkvmCompilerArgs Include="-debug:$(DebugType)" Condition=" '$(DebugType)' != 'none' " /> + <_IkvmCompilerArgs Include="-nowarn:$(NoWarn)" Condition=" '$(NoWarn)' != '' " /> + <_IkvmCompilerArgs Include="-warnaserror" Condition=" '$(TreatWarningsAsErrors)' == 'true' " /> + <_IkvmCompilerArgs Include="-warnaserror:$(WarningsAsErrors)" Condition=" '$(TreatWarningsAsErrors)' != 'true' And '$(WarningsAsErrors)' != '' " /> <_IkvmCompilerArgs Include="-assembly:$(AssemblyName)" /> <_IkvmCompilerArgs Include="-version:$(AssemblyVersion)" /> <_IkvmCompilerArgs Include="-runtime:$(IkvmRuntimeAssembly)" /> diff --git a/src/IKVM.NET.Sdk/targets/IKVM.Java.Core.Tasks.targets b/src/IKVM.NET.Sdk/targets/IKVM.Java.Core.Tasks.targets index f0106ab7b..49b6f507f 100644 --- a/src/IKVM.NET.Sdk/targets/IKVM.Java.Core.Tasks.targets +++ b/src/IKVM.NET.Sdk/targets/IKVM.Java.Core.Tasks.targets @@ -126,6 +126,9 @@ Platform="$(PlatformTarget.ToLowerInvariant())" Main="$(StartupObject)" Debug="$(DebugType)" + NoWarn="$(NoWarn)" + WarnAsError="$(TreatWarningsAsErrors)" + WarnAsErrorWarnings="$(WarningsAsErrors)" KeyFile="$(KeyOriginatorFile)" CompressResources="$(CompressResources)" ClassLoader="$(ClassLoader)" From 5edd1d2e57d004a0a1ea7881837a44f03cd96ee8 Mon Sep 17 00:00:00 2001 From: AliveDevil Date: Thu, 25 Jul 2024 13:49:21 +0200 Subject: [PATCH 2/8] Fix args --- src/IKVM.NET.Sdk/targets/IKVM.Java.Core.NoTasks.targets | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/IKVM.NET.Sdk/targets/IKVM.Java.Core.NoTasks.targets b/src/IKVM.NET.Sdk/targets/IKVM.Java.Core.NoTasks.targets index f6e455458..6125691e4 100644 --- a/src/IKVM.NET.Sdk/targets/IKVM.Java.Core.NoTasks.targets +++ b/src/IKVM.NET.Sdk/targets/IKVM.Java.Core.NoTasks.targets @@ -277,9 +277,9 @@ Value = b.ToString(); <_IkvmCompilerArgs Include="-nologo" /> <_IkvmCompilerArgs Include="-bootstrap" Condition=" '$(Bootstrap)' == 'true' " /> <_IkvmCompilerArgs Include="-debug:$(DebugType)" Condition=" '$(DebugType)' != 'none' " /> - <_IkvmCompilerArgs Include="-nowarn:$(NoWarn)" Condition=" '$(NoWarn)' != '' " /> + <_IkvmCompilerArgs Include="-nowarn:"$(NoWarn)"" Condition=" '$(NoWarn)' != '' " /> <_IkvmCompilerArgs Include="-warnaserror" Condition=" '$(TreatWarningsAsErrors)' == 'true' " /> - <_IkvmCompilerArgs Include="-warnaserror:$(WarningsAsErrors)" Condition=" '$(TreatWarningsAsErrors)' != 'true' And '$(WarningsAsErrors)' != '' " /> + <_IkvmCompilerArgs Include="-warnaserror:"$(WarningsAsErrors)"" Condition=" '$(TreatWarningsAsErrors)' != 'true' And '$(WarningsAsErrors)' != '' " /> <_IkvmCompilerArgs Include="-assembly:$(AssemblyName)" /> <_IkvmCompilerArgs Include="-version:$(AssemblyVersion)" /> <_IkvmCompilerArgs Include="-runtime:$(IkvmRuntimeAssembly)" /> From ff81eaf2b2c015b589be58a3e7b2769325e08cc9 Mon Sep 17 00:00:00 2001 From: AliveDevil Date: Thu, 25 Jul 2024 14:51:01 +0200 Subject: [PATCH 3/8] Use Replace function on string Property --- src/IKVM.NET.Sdk/targets/IKVM.Java.Core.NoTasks.targets | 4 ++-- src/IKVM.NET.Sdk/targets/IKVM.Java.Core.Tasks.targets | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/IKVM.NET.Sdk/targets/IKVM.Java.Core.NoTasks.targets b/src/IKVM.NET.Sdk/targets/IKVM.Java.Core.NoTasks.targets index 6125691e4..fae26f215 100644 --- a/src/IKVM.NET.Sdk/targets/IKVM.Java.Core.NoTasks.targets +++ b/src/IKVM.NET.Sdk/targets/IKVM.Java.Core.NoTasks.targets @@ -277,9 +277,9 @@ Value = b.ToString(); <_IkvmCompilerArgs Include="-nologo" /> <_IkvmCompilerArgs Include="-bootstrap" Condition=" '$(Bootstrap)' == 'true' " /> <_IkvmCompilerArgs Include="-debug:$(DebugType)" Condition=" '$(DebugType)' != 'none' " /> - <_IkvmCompilerArgs Include="-nowarn:"$(NoWarn)"" Condition=" '$(NoWarn)' != '' " /> + <_IkvmCompilerArgs Include="-nowarn:$(NoWarn.Replace(';', ','))" Condition=" '$(NoWarn)' != '' " /> <_IkvmCompilerArgs Include="-warnaserror" Condition=" '$(TreatWarningsAsErrors)' == 'true' " /> - <_IkvmCompilerArgs Include="-warnaserror:"$(WarningsAsErrors)"" Condition=" '$(TreatWarningsAsErrors)' != 'true' And '$(WarningsAsErrors)' != '' " /> + <_IkvmCompilerArgs Include="-warnaserror:$(WarningsAsErrors.Replace(';', ','))" Condition=" '$(TreatWarningsAsErrors)' != 'true' And '$(WarningsAsErrors)' != '' " /> <_IkvmCompilerArgs Include="-assembly:$(AssemblyName)" /> <_IkvmCompilerArgs Include="-version:$(AssemblyVersion)" /> <_IkvmCompilerArgs Include="-runtime:$(IkvmRuntimeAssembly)" /> diff --git a/src/IKVM.NET.Sdk/targets/IKVM.Java.Core.Tasks.targets b/src/IKVM.NET.Sdk/targets/IKVM.Java.Core.Tasks.targets index 49b6f507f..e0baab8a5 100644 --- a/src/IKVM.NET.Sdk/targets/IKVM.Java.Core.Tasks.targets +++ b/src/IKVM.NET.Sdk/targets/IKVM.Java.Core.Tasks.targets @@ -126,9 +126,9 @@ Platform="$(PlatformTarget.ToLowerInvariant())" Main="$(StartupObject)" Debug="$(DebugType)" - NoWarn="$(NoWarn)" + NoWarn="$(NoWarn.Replace(',', ';'))" WarnAsError="$(TreatWarningsAsErrors)" - WarnAsErrorWarnings="$(WarningsAsErrors)" + WarnAsErrorWarnings="$(WarningsAsErrors.Replace(',', ';'))" KeyFile="$(KeyOriginatorFile)" CompressResources="$(CompressResources)" ClassLoader="$(ClassLoader)" From 551de52570f80acbd32f872d670848cf5a73c334 Mon Sep 17 00:00:00 2001 From: AliveDevil Date: Tue, 30 Jul 2024 13:57:19 +0200 Subject: [PATCH 4/8] Handle MSBuild-style warnings (Prefix0000) --- .../CompilerClassLoader.cs | 8 +- .../IkvmImporterInternal.cs | 75 ++++-- src/IKVM.Tools.Importer/StaticCompiler.cs | 247 +----------------- 3 files changed, 52 insertions(+), 278 deletions(-) diff --git a/src/IKVM.Tools.Importer/CompilerClassLoader.cs b/src/IKVM.Tools.Importer/CompilerClassLoader.cs index 5c31cb152..e5c527f5f 100644 --- a/src/IKVM.Tools.Importer/CompilerClassLoader.cs +++ b/src/IKVM.Tools.Importer/CompilerClassLoader.cs @@ -3406,8 +3406,8 @@ sealed class CompilerOptions internal uint fileAlignment; internal bool highentropyva; internal List sharedclassloader; // should *not* be deep copied in Copy(), because we want the list of all compilers that share a class loader - internal Dictionary suppressWarnings = new Dictionary(); - internal Dictionary errorWarnings = new Dictionary(); // treat specific warnings as errors + internal HashSet suppressWarnings = new HashSet(StringComparer.OrdinalIgnoreCase); + internal HashSet errorWarnings = new HashSet(StringComparer.OrdinalIgnoreCase); internal bool warnaserror; // treat all warnings as errors internal FileInfo writeSuppressWarningsFile; internal List proxies = new List(); @@ -3429,8 +3429,8 @@ internal CompilerOptions Copy() { copy.externalResources = new Dictionary(externalResources); } - copy.suppressWarnings = new Dictionary(suppressWarnings); - copy.errorWarnings = new Dictionary(errorWarnings); + copy.suppressWarnings = new(suppressWarnings, StringComparer.OrdinalIgnoreCase); + copy.errorWarnings = new(errorWarnings, StringComparer.OrdinalIgnoreCase); return copy; } diff --git a/src/IKVM.Tools.Importer/IkvmImporterInternal.cs b/src/IKVM.Tools.Importer/IkvmImporterInternal.cs index 2b8d100d7..046765dab 100644 --- a/src/IKVM.Tools.Importer/IkvmImporterInternal.cs +++ b/src/IKVM.Tools.Importer/IkvmImporterInternal.cs @@ -748,15 +748,7 @@ void ContinueParseCommandLine(RuntimeContext context, StaticCompiler compiler, I } else if (s.StartsWith("-nowarn:")) { - foreach (var w in s.Substring(8).Split(',')) - { - // lame way to chop off the leading zeroes - string ws = w; - while (ws.StartsWith("0")) - ws = ws.Substring(1); - - options.suppressWarnings[ws] = ws; - } + HandleWarnArg(options.suppressWarnings, s.Substring(8)); } else if (s == "-warnaserror") { @@ -764,15 +756,7 @@ void ContinueParseCommandLine(RuntimeContext context, StaticCompiler compiler, I } else if (s.StartsWith("-warnaserror:")) { - foreach (string w in s.Substring(13).Split(',')) - { - // lame way to chop off the leading zeroes - string ws = w; - while (ws.StartsWith("0")) - ws = ws.Substring(1); - - options.errorWarnings[ws] = ws; - } + HandleWarnArg(options.errorWarnings, s.Substring(8)); } else if (s.StartsWith("-runtime:")) { @@ -1449,20 +1433,18 @@ internal static void IssueMessage(StaticCompiler compiler, CompilerOptions optio return; } - string key = ((int)msgId).ToString(); - for (int i = 0; ; i++) + var msgIdKey = $"{(int)msgId}"; + string key = msgIdKey; + foreach (var item in values) { - if (options.suppressWarnings.ContainsKey(key)) + if (options.suppressWarnings.Contains(key)) { return; } - if (i == values.Length) - { - break; - } - key += ":" + values[i]; + + key = $"{key}:{item}"; } - options.suppressWarnings.Add(key, key); + options.suppressWarnings.Add(key); if (options.writeSuppressWarningsFile != null) { File.AppendAllText(options.writeSuppressWarningsFile.FullName, "-nowarn:" + key + Environment.NewLine); @@ -1668,8 +1650,8 @@ internal static void IssueMessage(StaticCompiler compiler, CompilerOptions optio } bool error = msgId >= Message.StartErrors || (options.warnaserror && msgId >= Message.StartWarnings) - || options.errorWarnings.ContainsKey(key) - || options.errorWarnings.ContainsKey(((int)msgId).ToString()); + || options.errorWarnings.Contains(key) + || options.errorWarnings.Contains(msgIdKey); Console.Error.Write("{0} IKVMC{1:D4}: ", error ? "error" : msgId < Message.StartWarnings ? "note" : "warning", (int)msgId); if (error && Message.StartWarnings <= msgId && msgId < Message.StartErrors) { @@ -1689,6 +1671,41 @@ internal static void IssueMessage(StaticCompiler compiler, CompilerOptions optio } } + internal static void HandleWarnArg(ICollection target, string arg) + { + foreach (var w in arg.Split(',')) + { + // Strip IKVMC prefix + int prefixStart = w.StartsWith("IKVMC", StringComparison.OrdinalIgnoreCase) ? 5 : 0; + int contextIndex = w.IndexOf(':', prefixStart); + string context = string.Empty; + string parse; + if(contextIndex != -1) + { + // context includes ':' separator + context = w.Substring(contextIndex); + parse = w.Substring(prefixStart, contextIndex - prefixStart); + } + else + { + parse = w.Substring(prefixStart); + } + + if (!int.TryParse(parse, out var intResult)) + { + if (!Enum.TryParse(parse, out var namedResult)) + { + continue; // silently continue + } + + // Warnings are handled as int. + intResult = (int)namedResult; + } + + // Check IssueMessage + target.Add($"{intResult}{context}"); + } + } } } diff --git a/src/IKVM.Tools.Importer/StaticCompiler.cs b/src/IKVM.Tools.Importer/StaticCompiler.cs index bfc78180a..ea2460cae 100644 --- a/src/IKVM.Tools.Importer/StaticCompiler.cs +++ b/src/IKVM.Tools.Importer/StaticCompiler.cs @@ -230,7 +230,7 @@ internal void IssueMissingTypeMessage(Type type) internal void SuppressWarning(CompilerOptions options, Message message, string name) { - options.suppressWarnings[(int)message + ":" + name] = null; + options.suppressWarnings.Add($"{(int)message}:{name}"); } internal void IssueMessage(Message msgId, params string[] values) @@ -240,250 +240,7 @@ internal void IssueMessage(Message msgId, params string[] values) internal void IssueMessage(CompilerOptions options, Message msgId, params string[] values) { - if (errorCount != 0 && msgId < Message.StartErrors && !options.warnaserror) - { - // don't display any warnings after we've emitted an error message - return; - } - - string key = ((int)msgId).ToString(); - for (int i = 0; ; i++) - { - if (options.suppressWarnings.ContainsKey(key)) - { - return; - } - if (i == values.Length) - { - break; - } - key += ":" + values[i]; - } - options.suppressWarnings.Add(key, key); - if (options.writeSuppressWarningsFile != null) - { - File.AppendAllText(options.writeSuppressWarningsFile.FullName, "-nowarn:" + key + Environment.NewLine); - } - string msg; - switch (msgId) - { - case Message.MainMethodFound: - msg = "Found main method in class \"{0}\""; - break; - case Message.OutputFileIs: - msg = "Output file is \"{0}\""; - break; - case Message.AutoAddRef: - msg = "Automatically adding reference to \"{0}\""; - break; - case Message.MainMethodFromManifest: - msg = "Using main class \"{0}\" based on jar manifest"; - break; - case Message.ClassNotFound: - msg = "Class \"{0}\" not found"; - break; - case Message.ClassFormatError: - msg = "Unable to compile class \"{0}\"" + Environment.NewLine + - " (class format error \"{1}\")"; - break; - case Message.DuplicateClassName: - msg = "Duplicate class name: \"{0}\""; - break; - case Message.IllegalAccessError: - msg = "Unable to compile class \"{0}\"" + Environment.NewLine + - " (illegal access error \"{1}\")"; - break; - case Message.VerificationError: - msg = "Unable to compile class \"{0}\"" + Environment.NewLine + - " (verification error \"{1}\")"; - break; - case Message.NoClassDefFoundError: - msg = "Unable to compile class \"{0}\"" + Environment.NewLine + - " (missing class \"{1}\")"; - break; - case Message.GenericUnableToCompileError: - msg = "Unable to compile class \"{0}\"" + Environment.NewLine + - " (\"{1}\": \"{2}\")"; - break; - case Message.DuplicateResourceName: - msg = "Skipping resource (name clash): \"{0}\""; - break; - case Message.SkippingReferencedClass: - msg = "Skipping class: \"{0}\"" + Environment.NewLine + - " (class is already available in referenced assembly \"{1}\")"; - break; - case Message.NoJniRuntime: - msg = "Unable to load runtime JNI assembly"; - break; - case Message.EmittedNoClassDefFoundError: - msg = "Emitted java.lang.NoClassDefFoundError in \"{0}\"" + Environment.NewLine + - " (\"{1}\")"; - break; - case Message.EmittedIllegalAccessError: - msg = "Emitted java.lang.IllegalAccessError in \"{0}\"" + Environment.NewLine + - " (\"{1}\")"; - break; - case Message.EmittedInstantiationError: - msg = "Emitted java.lang.InstantiationError in \"{0}\"" + Environment.NewLine + - " (\"{1}\")"; - break; - case Message.EmittedIncompatibleClassChangeError: - msg = "Emitted java.lang.IncompatibleClassChangeError in \"{0}\"" + Environment.NewLine + - " (\"{1}\")"; - break; - case Message.EmittedNoSuchFieldError: - msg = "Emitted java.lang.NoSuchFieldError in \"{0}\"" + Environment.NewLine + - " (\"{1}\")"; - break; - case Message.EmittedAbstractMethodError: - msg = "Emitted java.lang.AbstractMethodError in \"{0}\"" + Environment.NewLine + - " (\"{1}\")"; - break; - case Message.EmittedNoSuchMethodError: - msg = "Emitted java.lang.NoSuchMethodError in \"{0}\"" + Environment.NewLine + - " (\"{1}\")"; - break; - case Message.EmittedLinkageError: - msg = "Emitted java.lang.LinkageError in \"{0}\"" + Environment.NewLine + - " (\"{1}\")"; - break; - case Message.EmittedVerificationError: - msg = "Emitted java.lang.VerificationError in \"{0}\"" + Environment.NewLine + - " (\"{1}\")"; - break; - case Message.EmittedClassFormatError: - msg = "Emitted java.lang.ClassFormatError in \"{0}\"" + Environment.NewLine + - " (\"{1}\")"; - break; - case Message.InvalidCustomAttribute: - msg = "Error emitting \"{0}\" custom attribute" + Environment.NewLine + - " (\"{1}\")"; - break; - case Message.IgnoredCustomAttribute: - msg = "Custom attribute \"{0}\" was ignored" + Environment.NewLine + - " (\"{1}\")"; - break; - case Message.AssumeAssemblyVersionMatch: - msg = "Assuming assembly reference \"{0}\" matches \"{1}\", you may need to supply runtime policy"; - break; - case Message.InvalidDirectoryInLibOptionPath: - msg = "Directory \"{0}\" specified in -lib option is not valid"; - break; - case Message.InvalidDirectoryInLibEnvironmentPath: - msg = "Directory \"{0}\" specified in LIB environment is not valid"; - break; - case Message.LegacySearchRule: - msg = "Found assembly \"{0}\" using legacy search rule, please append '.dll' to the reference"; - break; - case Message.AssemblyLocationIgnored: - msg = "Assembly \"{0}\" is ignored as previously loaded assembly \"{1}\" has the same identity \"{2}\""; - break; - case Message.InterfaceMethodCantBeInternal: - msg = "Ignoring @ikvm.lang.Internal annotation on interface method" + Environment.NewLine + - " (\"{0}.{1}{2}\")"; - break; - case Message.NonPrimaryAssemblyReference: - msg = "Referenced assembly \"{0}\" is not the primary assembly of a shared class loader group, please reference primary assembly \"{1}\" instead"; - break; - case Message.MissingType: - msg = "Reference to type \"{0}\" claims it is defined in \"{1}\", but it could not be found"; - break; - case Message.MissingReference: - msg = "The type '{0}' is defined in an assembly that is not referenced. You must add a reference to assembly '{1}'"; - break; - case Message.DuplicateAssemblyReference: - msg = "Duplicate assembly reference \"{0}\""; - break; - case Message.UnableToResolveType: - msg = "Reference in \"{0}\" to type \"{1}\" claims it is defined in \"{2}\", but it could not be found"; - break; - case Message.StubsAreDeprecated: - msg = "Compiling stubs is deprecated. Please add a reference to assembly \"{0}\" instead."; - break; - case Message.WrongClassName: - msg = "Unable to compile \"{0}\" (wrong name: \"{1}\")"; - break; - case Message.ReflectionCallerClassRequiresCallerID: - msg = "Reflection.getCallerClass() called from non-CallerID method" + Environment.NewLine + - " (\"{0}.{1}{2}\")"; - break; - case Message.LegacyAssemblyAttributesFound: - msg = "Legacy assembly attributes container found. Please use the -assemblyattributes: option."; - break; - case Message.UnableToCreateLambdaFactory: - msg = "Unable to create static lambda factory."; - break; - case Message.UnableToCreateProxy: - msg = "Unable to create proxy \"{0}\"" + Environment.NewLine + - " (\"{1}\")"; - break; - case Message.DuplicateProxy: - msg = "Duplicate proxy \"{0}\""; - break; - case Message.MapXmlUnableToResolveOpCode: - msg = "Unable to resolve opcode in remap file: {0}"; - break; - case Message.MapXmlError: - msg = "Error in remap file: {0}"; - break; - case Message.InputFileNotFound: - msg = "Source file '{0}' not found"; - break; - case Message.UnknownFileType: - msg = "Unknown file type: {0}"; - break; - case Message.UnknownElementInMapFile: - msg = "Unknown element {0} in remap file, line {1}, column {2}"; - break; - case Message.UnknownAttributeInMapFile: - msg = "Unknown attribute {0} in remap file, line {1}, column {2}"; - break; - case Message.InvalidMemberNameInMapFile: - msg = "Invalid {0} name '{1}' in remap file in class {2}"; - break; - case Message.InvalidMemberSignatureInMapFile: - msg = "Invalid {0} signature '{3}' in remap file for {0} {1}.{2}"; - break; - case Message.InvalidPropertyNameInMapFile: - msg = "Invalid property {0} name '{3}' in remap file for property {1}.{2}"; - break; - case Message.InvalidPropertySignatureInMapFile: - msg = "Invalid property {0} signature '{3}' in remap file for property {1}.{2}"; - break; - case Message.UnknownWarning: - msg = "{0}"; - break; - case Message.CallerSensitiveOnUnsupportedMethod: - msg = "CallerSensitive annotation on unsupported method" + Environment.NewLine + - " (\"{0}.{1}{2}\")"; - break; - case Message.RemappedTypeMissingDefaultInterfaceMethod: - msg = "{0} does not implement default interface method {1}"; - break; - default: - throw new InvalidProgramException(); - } - bool error = msgId >= Message.StartErrors - || (options.warnaserror && msgId >= Message.StartWarnings) - || options.errorWarnings.ContainsKey(key) - || options.errorWarnings.ContainsKey(((int)msgId).ToString()); - Console.Error.Write("{0} IKVMC{1:D4}: ", error ? "error" : msgId < Message.StartWarnings ? "note" : "warning", (int)msgId); - if (error && Message.StartWarnings <= msgId && msgId < Message.StartErrors) - { - Console.Error.Write("Warning as Error: "); - } - Console.Error.WriteLine(msg, values); - if (options != this.rootTarget && options.path != null) - { - Console.Error.WriteLine(" (in {0})", options.path); - } - if (error) - { - if (++errorCount == 100) - { - throw new FatalCompilerErrorException(Message.MaximumErrorCountReached); - } - } + IkvmImporterInternal.IssueMessage(this, options, msgId, values); } } From 481216acf412227d881ff5cc26c06278f7cc3e73 Mon Sep 17 00:00:00 2001 From: AliveDevil Date: Tue, 30 Jul 2024 14:10:10 +0200 Subject: [PATCH 5/8] Restore previous behavior --- src/IKVM.Tools.Importer/IkvmImporterInternal.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/IKVM.Tools.Importer/IkvmImporterInternal.cs b/src/IKVM.Tools.Importer/IkvmImporterInternal.cs index 046765dab..c27bf3c4a 100644 --- a/src/IKVM.Tools.Importer/IkvmImporterInternal.cs +++ b/src/IKVM.Tools.Importer/IkvmImporterInternal.cs @@ -1435,14 +1435,17 @@ internal static void IssueMessage(StaticCompiler compiler, CompilerOptions optio var msgIdKey = $"{(int)msgId}"; string key = msgIdKey; - foreach (var item in values) + for (int i = 0; ; i++) { if (options.suppressWarnings.Contains(key)) { return; } - - key = $"{key}:{item}"; + if (i == values.Length) + { + break; + } + key = $"{key}:{values[i]}"; } options.suppressWarnings.Add(key); if (options.writeSuppressWarningsFile != null) From 1c5c47de3a901c97db5a32a865de1f3c58336b67 Mon Sep 17 00:00:00 2001 From: AliveDevil Date: Wed, 31 Jul 2024 09:49:00 +0200 Subject: [PATCH 6/8] Missed --- src/IKVM.Tools.Importer/IkvmImporterInternal.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/IKVM.Tools.Importer/IkvmImporterInternal.cs b/src/IKVM.Tools.Importer/IkvmImporterInternal.cs index c27bf3c4a..ff50f00a1 100644 --- a/src/IKVM.Tools.Importer/IkvmImporterInternal.cs +++ b/src/IKVM.Tools.Importer/IkvmImporterInternal.cs @@ -756,7 +756,7 @@ void ContinueParseCommandLine(RuntimeContext context, StaticCompiler compiler, I } else if (s.StartsWith("-warnaserror:")) { - HandleWarnArg(options.errorWarnings, s.Substring(8)); + HandleWarnArg(options.errorWarnings, s.Substring(13)); } else if (s.StartsWith("-runtime:")) { From 3b7e2a905f9459e44334ee5eb9b867ce4c33f61e Mon Sep 17 00:00:00 2001 From: AliveDevil Date: Wed, 31 Jul 2024 14:04:42 +0200 Subject: [PATCH 7/8] Forward messages from IKVMc as-is --- src/IKVM.MSBuild.Tasks/IkvmToolTaskDiagnosticWriter.cs | 4 ++++ src/IKVM.Tools.Runner/Importer/IkvmImporterLauncher.cs | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/IKVM.MSBuild.Tasks/IkvmToolTaskDiagnosticWriter.cs b/src/IKVM.MSBuild.Tasks/IkvmToolTaskDiagnosticWriter.cs index 80ec27e7f..1dab4bebb 100644 --- a/src/IKVM.MSBuild.Tasks/IkvmToolTaskDiagnosticWriter.cs +++ b/src/IKVM.MSBuild.Tasks/IkvmToolTaskDiagnosticWriter.cs @@ -58,6 +58,10 @@ public Task ReceiveAsync(IkvmToolDiagnosticEvent @event) logger.LogWarning(@event.Message, @event.MessageArgs); writer?.WriteLine("ERROR: " + @event.Message, @event.MessageArgs); break; + + case 0: // Unknown Level, passthrough message + logger.LogMessage(@event.Message, @event.MessageArgs); + break; } } catch diff --git a/src/IKVM.Tools.Runner/Importer/IkvmImporterLauncher.cs b/src/IKVM.Tools.Runner/Importer/IkvmImporterLauncher.cs index 2a4673a91..c3c9f6f9e 100644 --- a/src/IKVM.Tools.Runner/Importer/IkvmImporterLauncher.cs +++ b/src/IKVM.Tools.Runner/Importer/IkvmImporterLauncher.cs @@ -299,8 +299,9 @@ public async Task ExecuteAsync(IkvmImporterOptions options, CancellationTok await LogEvent(IkvmToolDiagnosticEventLevel.Debug, "Executing {0} {1}", cli.TargetFilePath, cli.Arguments); // send output to MSBuild - cli = cli.WithStandardErrorPipe(PipeTarget.ToDelegate(i => LogEvent(IkvmToolDiagnosticEventLevel.Error, i))); - cli = cli.WithStandardOutputPipe(PipeTarget.ToDelegate(i => LogEvent(IkvmToolDiagnosticEventLevel.Debug, i))); + var logUnknown = PipeTarget.ToDelegate(i => LogEvent(0, i)); + cli = cli.WithStandardErrorPipe(logUnknown); + cli = cli.WithStandardOutputPipe(logUnknown); // combine manual cancellation with timeout var ctk = cts.Token; From 3859829435fdee9f0a8610f94c1c1dbb97eb5f19 Mon Sep 17 00:00:00 2001 From: AliveDevil Date: Wed, 31 Jul 2024 14:45:58 +0200 Subject: [PATCH 8/8] Use Unknown enum value --- src/IKVM.MSBuild.Tasks/IkvmToolTaskDiagnosticWriter.cs | 2 +- src/IKVM.Tools.Runner/IkvmToolDiagnosticEventLevel.cs | 1 + src/IKVM.Tools.Runner/Importer/IkvmImporterLauncher.cs | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/IKVM.MSBuild.Tasks/IkvmToolTaskDiagnosticWriter.cs b/src/IKVM.MSBuild.Tasks/IkvmToolTaskDiagnosticWriter.cs index 1dab4bebb..a08394c4d 100644 --- a/src/IKVM.MSBuild.Tasks/IkvmToolTaskDiagnosticWriter.cs +++ b/src/IKVM.MSBuild.Tasks/IkvmToolTaskDiagnosticWriter.cs @@ -59,7 +59,7 @@ public Task ReceiveAsync(IkvmToolDiagnosticEvent @event) writer?.WriteLine("ERROR: " + @event.Message, @event.MessageArgs); break; - case 0: // Unknown Level, passthrough message + case IkvmToolDiagnosticEventLevel.Unknown: // Unknown Level, passthrough message logger.LogMessage(@event.Message, @event.MessageArgs); break; } diff --git a/src/IKVM.Tools.Runner/IkvmToolDiagnosticEventLevel.cs b/src/IKVM.Tools.Runner/IkvmToolDiagnosticEventLevel.cs index bfef692c9..1190b62bb 100644 --- a/src/IKVM.Tools.Runner/IkvmToolDiagnosticEventLevel.cs +++ b/src/IKVM.Tools.Runner/IkvmToolDiagnosticEventLevel.cs @@ -11,6 +11,7 @@ public enum IkvmToolDiagnosticEventLevel Information, Warning, Error, + Unknown = -1 } diff --git a/src/IKVM.Tools.Runner/Importer/IkvmImporterLauncher.cs b/src/IKVM.Tools.Runner/Importer/IkvmImporterLauncher.cs index c3c9f6f9e..2497a4bed 100644 --- a/src/IKVM.Tools.Runner/Importer/IkvmImporterLauncher.cs +++ b/src/IKVM.Tools.Runner/Importer/IkvmImporterLauncher.cs @@ -299,7 +299,7 @@ public async Task ExecuteAsync(IkvmImporterOptions options, CancellationTok await LogEvent(IkvmToolDiagnosticEventLevel.Debug, "Executing {0} {1}", cli.TargetFilePath, cli.Arguments); // send output to MSBuild - var logUnknown = PipeTarget.ToDelegate(i => LogEvent(0, i)); + var logUnknown = PipeTarget.ToDelegate(i => LogEvent(IkvmToolDiagnosticEventLevel.Unknown, i)); cli = cli.WithStandardErrorPipe(logUnknown); cli = cli.WithStandardOutputPipe(logUnknown);