Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tools] Ignore a few warnings by default. Fixes #20670. #20805

Merged
merged 1 commit into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dotnet/targets/Xamarin.Shared.Sdk.targets
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,7 @@
TargetFramework=$(_ComputedTargetFrameworkMoniker)
UseLlvm=$(MtouchUseLlvm)
Verbosity=$(_BundlerVerbosity)
Warn=$(_BundlerWarn)
WarnAsError=$(_BundlerWarnAsError)
XamarinNativeLibraryDirectory=$(_XamarinNativeLibraryDirectory)
XamarinRuntime=$(_XamarinRuntime)
Expand Down
12 changes: 12 additions & 0 deletions msbuild/Xamarin.MacDev.Tasks/Tasks/ParseBundlerArguments.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ public class ParseBundlerArguments : XamarinTask {
[Output]
public int Verbosity { get; set; }

[Output]
public string Warn { get; set; }

[Output]
public string WarnAsError { get; set; }

Expand Down Expand Up @@ -233,6 +236,15 @@ public override bool Execute ()
NoWarn += "," + value;
}
break;
case "warn":
if (!hasValue)
value = "-1"; // all warnings
if (string.IsNullOrEmpty (Warn)) {
Warn = value;
} else {
Warn += "," + value;
}
break;
default:
// Handle arguments like -vvv and -qqqq
if (value.Length == 0 && name.Length > 1 && name.All (ch => ch == name [0])) {
Expand Down
1 change: 1 addition & 0 deletions msbuild/Xamarin.Shared/Xamarin.Shared.targets
Original file line number Diff line number Diff line change
Expand Up @@ -2039,6 +2039,7 @@ Copyright (C) 2018 Microsoft. All rights reserved.
<Output TaskParameter="SkipMarkingNSObjectsInUserAssemblies" PropertyName="_SkipMarkingNSObjectsInUserAssemblies" />
<Output TaskParameter="Verbosity" PropertyName="_BundlerVerbosity" />
<Output TaskParameter="WarnAsError" PropertyName="_BundlerWarnAsError" />
<Output TaskParameter="Warn" PropertyName="_BundlerWarn" />
<Output TaskParameter="XmlDefinitions" ItemName="_BundlerXmlDefinitions" />
<Output TaskParameter="NoStrip" PropertyName="EnableAssemblyILStripping" />
</ParseBundlerArguments>
Expand Down
13 changes: 13 additions & 0 deletions tools/common/Application.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1797,5 +1797,18 @@ public bool VerifyDynamicFramework (string framework_path)

return dynamic;
}

static Application ()
{
SetDefaultHiddenWarnings ();
}

public static void SetDefaultHiddenWarnings ()
{
// People don't like these warnings (#20670), and they also complicate our tests, so ignore them.
ErrorHelper.ParseWarningLevel (ErrorHelper.WarningLevel.Disable, "4178"); // The class '{0}' will not be registered because the {1} framework has been removed from the {2} SDK.
ErrorHelper.ParseWarningLevel (ErrorHelper.WarningLevel.Disable, "4189"); // The class '{0}' will not be registered because it has been removed from the {1} SDK.
ErrorHelper.ParseWarningLevel (ErrorHelper.WarningLevel.Disable, "4190"); // The class '{0}' will not be registered because the {1} framework has been deprecated from the {2} SDK.
}
}
}
7 changes: 7 additions & 0 deletions tools/common/Driver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,13 @@ static bool ParseOptions (Application app, Mono.Options.OptionSet options, strin
throw ErrorHelper.CreateError (26, ex, Errors.MX0026, "--nowarn", ex.Message);
}
});
options.Add ("warn:", "An optional comma-separated list of warning codes to report as warnings (if no warnings are specified all warnings reported).", v => {
try {
ErrorHelper.ParseWarningLevel (ErrorHelper.WarningLevel.Warning, v);
} catch (Exception ex) {
throw ErrorHelper.CreateError (26, ex, Errors.MX0026, "--warn", ex.Message);
}
});
options.Add ("coop:", "If the GC should run in cooperative mode.", v => { app.EnableCoopGC = ParseBool (v, "coop"); }, hidden: true);
options.Add ("sgen-conc", "Enable the *experimental* concurrent garbage collector.", v => { app.EnableSGenConc = true; });
options.Add ("marshal-objectivec-exceptions:", "Specify how Objective-C exceptions should be marshalled. Valid values: default, unwindmanagedcode, throwmanagedexception, abort and disable. The default depends on the target platform (on watchOS the default is 'throwmanagedexception', while on all other platforms it's 'disable').", v => {
Expand Down
7 changes: 7 additions & 0 deletions tools/dotnet-linker/LinkerConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,13 @@ public static LinkerConfiguration GetInstance (LinkContext context)
throw new InvalidOperationException ($"Invalid Verbosity '{value}' in {linker_file}");
Driver.Verbosity += verbosity;
break;
case "Warn":
try {
ErrorHelper.ParseWarningLevel (ErrorHelper.WarningLevel.Warning, value);
} catch (Exception ex) {
throw new InvalidOperationException ($"Invalid Warn '{value}' in {linker_file}", ex);
}
break;
case "WarnAsError":
try {
ErrorHelper.ParseWarningLevel (ErrorHelper.WarningLevel.Error, value);
Expand Down