-
Notifications
You must be signed in to change notification settings - Fork 519
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
XA0106 warnings in Xamarin.Forms/Android project #1988
Comments
Please fix these warnings so they can be suppressed. |
Context: xamarin#1988 Also replace the `/nowarn` command line switch with its alias `/warnasmessage` to help maintain a clear distcintion between this command line switch and the *unrelated* `$(NoWarn)` MSBuild property. I have verified that both the `/warnasmessage` command line switch and the `$(MSBuildWarningsAsMessages)` MSBuild property successfully suppress `XAnnnn` warnings such as `XA4214`. The `/nowarn` command line switch for MSBuild does *not* correspond to the `$(NoWarn)` MSBuild property. In fact, the `$(NoWarn)` property is not used at all by the MSBuild logger itself. It is instead passed into [the `<Csc/>` task in C# projects][0], [the `<Vbc/>` task in Visual Basic projects][1], and [the `<PackTask/>` in the NuGet packaging targets][2], which then *themselves* skip emitting the specified warnings. In the past, MSBuild did not provide a mechanism to filter warnings via the MSBuild logger itself, so SDK targets had to implement the functionality themsleves. But then the `/nowarn` (aka `/warnasmessage`) command line switch was added [a few years ago][3] to enable filtering by the MSBuild logger. The complication is that the meaning of the `$(NoWarn)` property was already well established by then, so instead of changing the semantics of that existing property, the team [added a separate `$(MSBuildWarningsAsMessages)` property][4]. Another little complication is that the [MSBuild command-line reference][5] does not yet mention the `/nowarn` or `/warnasmessage` switch, and the [common MSBuild project properties documentation][6] does not yet mention the `$(MSBuildWarningsAsMessages)` property. Also, there is not yet a GUI representation of this property in the Visual Studio property pages. (The **Build > Errors and warnings > Suppress warnings** property pages setting corresponds to older the `$(NoWarn)` property instead.) [0]: https://github.com/microsoft/msbuild/blob/v16.0.461.62831/src/Tasks/Microsoft.CSharp.CurrentVersion.targets#L259 [1]: https://github.com/microsoft/msbuild/blob/v16.0.461.62831/src/Tasks/Microsoft.VisualBasic.CurrentVersion.targets#L247 [2]: https://github.com/NuGet/NuGet.Client/blob/5.2.0.6045/src/NuGet.Core/NuGet.Build.Tasks.Pack/NuGet.Build.Tasks.Pack.targets#L246 [3]: dotnet/msbuild@4287837 [4]: dotnet/msbuild@01f9915 [5]: https://docs.microsoft.com/visualstudio/msbuild/msbuild-command-line-reference?view=vs-2019 [6]: https://docs.microsoft.com/visualstudio/msbuild/common-msbuild-project-properties?view=vs-2019
Context: xamarin#1988 Also replace the `/nowarn` command line switch with its alias `/warnasmessage` to help maintain a clear distcintion between this command line switch and the *unrelated* `$(NoWarn)` MSBuild property. I have verified that both the `/warnasmessage` command line switch and the `$(MSBuildWarningsAsMessages)` MSBuild property successfully suppress `XAnnnn` warnings such as `XA4214`. The `/nowarn` command line switch for MSBuild does *not* correspond to the `$(NoWarn)` MSBuild property. In fact, the `$(NoWarn)` property is not used at all by the MSBuild logger itself. It is instead passed into [the `<Csc/>` task in C# projects][0], [the `<Vbc/>` task in Visual Basic projects][1], and [the `<PackTask/>` in the NuGet packaging targets][2], which then *themselves* skip emitting the specified warnings. In the past, MSBuild did not provide a mechanism to filter warnings via the MSBuild logger itself, so SDK targets had to implement the functionality themsleves. But then the `/nowarn` (aka `/warnasmessage`) command line switch was added [a few years ago][3] to enable filtering by the MSBuild logger. The complication is that the meaning of the `$(NoWarn)` property was already well established by then, so instead of changing the semantics of that existing property, the team [added a separate `$(MSBuildWarningsAsMessages)` property][4]. Another little complication is that the [MSBuild command-line reference][5] does not yet mention the `/nowarn` or `/warnasmessage` switch, and the [common MSBuild project properties documentation][6] does not yet mention the `$(MSBuildWarningsAsMessages)` property. Also, there is not yet a GUI representation of this property in the Visual Studio property pages. (The **Build > Errors and warnings > Suppress warnings** property pages setting corresponds to older the `$(NoWarn)` property instead.) [0]: https://github.com/microsoft/msbuild/blob/v16.0.461.62831/src/Tasks/Microsoft.CSharp.CurrentVersion.targets#L259 [1]: https://github.com/microsoft/msbuild/blob/v16.0.461.62831/src/Tasks/Microsoft.VisualBasic.CurrentVersion.targets#L247 [2]: https://github.com/NuGet/NuGet.Client/blob/5.2.0.6045/src/NuGet.Core/NuGet.Build.Tasks.Pack/NuGet.Build.Tasks.Pack.targets#L246 [3]: dotnet/msbuild@4287837 [4]: dotnet/msbuild@01f9915 [5]: https://docs.microsoft.com/visualstudio/msbuild/msbuild-command-line-reference?view=vs-2019 [6]: https://docs.microsoft.com/visualstudio/msbuild/common-msbuild-project-properties?view=vs-2019
Thanks for this report, and apologies this issue didn't get a reply sooner! By chance, these XA0106 warnings came up again in the context of the current Visual Studio 2019 version 16.2 Preview version, so I was looking into the story a bit more today. In short, I learned that there is already a way to suppress the warnings, but it isn't too well documented. To suppress the warnings, you can either:
Additional background infoOne of the tricky things about the Another reason these settings are tricky is that they are different from the One more potentially confusing detail to be aware of is that MSBuild offers 2 different names for the |
Context: xamarin#1988 Also replace the `/nowarn` command line switch with its alias `/warnasmessage` to help emphasize the distinction between this command line switch and the *unrelated* `$(NoWarn)` MSBuild property. I have verified that both the `/warnasmessage` command line switch and the `$(MSBuildWarningsAsMessages)` MSBuild property successfully suppress `XAnnnn` warnings such as `XA4214`. The reason behind these changes is that I learned that the `/nowarn` command line switch for MSBuild does *not* correspond to the `$(NoWarn)` MSBuild property. In fact, the `$(NoWarn)` property is not used at all by the MSBuild logger itself. It is instead passed into the [`<Csc/>` task in C# projects][0], the [`<Vbc/>` task in Visual Basic projects][1], and the [`MSBuildRestoreUtility` class][2] and [`<PackTask/>` task][3] in the NuGet package manager, allowing those tools to suppress the warnings internally, before MSBuild sees them. In the past, MSBuild did not provide a mechanism to suppress warnings via the MSBuild logger itself, so Xamarin.Android would have had to provide its own mechanism to suppress warnings internally. But as of [a few years ago][4], MSBuild now includes a `/nowarn` (aka `/warnasmessage`) command line switch to control how the MSBuild logger itself suppresses warnings. The complication is that the meaning of the `$(NoWarn)` property was already well established by then, so instead of changing the semantics of that existing property, the team [added a separate `$(MSBuildWarningsAsMessages)` property][5] to go along with the new command line switch. Another little complication is that the [MSBuild command-line reference][6] does not yet mention the `/nowarn` or `/warnasmessage` switch, and the [common MSBuild project properties documentation][7] does not yet mention the `$(MSBuildWarningsAsMessages)` property. The Visual Studio property pages UI doesn't currently include this property either. (The [**Build > Errors and warnings > Suppress warnings**][8] Visual Studio property pages setting corresponds to older the `$(NoWarn)` property instead.) [0]: https://github.com/microsoft/msbuild/blob/v16.0.461.62831/src/Tasks/Microsoft.CSharp.CurrentVersion.targets#L259 [1]: https://github.com/microsoft/msbuild/blob/v16.0.461.62831/src/Tasks/Microsoft.VisualBasic.CurrentVersion.targets#L247 [2]: https://github.com/NuGet/NuGet.Client/blob/5.2.0.6045/src/NuGet.Core/NuGet.Commands/RestoreCommand/Utility/MSBuildRestoreUtility.cs#L606 [3]: https://github.com/NuGet/NuGet.Client/blob/5.2.0.6045/src/NuGet.Core/NuGet.Build.Tasks.Pack/NuGet.Build.Tasks.Pack.targets#L246 [4]: dotnet/msbuild@4287837 [5]: dotnet/msbuild@01f9915 [6]: https://docs.microsoft.com/visualstudio/msbuild/msbuild-command-line-reference?view=vs-2019 [7]: https://docs.microsoft.com/visualstudio/msbuild/common-msbuild-project-properties?view=vs-2019 [8]: https://docs.microsoft.com/en-us/visualstudio/ide/how-to-suppress-compiler-warnings?view=vs-2019#suppress-specific-warnings-for-visual-c-or-f
Context: #1988 Replace the `msbuild /nowarn` command line switch with its alias `msbuild /warnasmessage` to help emphasize the distinction between this command line switch and the *unrelated* `$(NoWarn)` MSBuild property. I have verified that both the `/warnasmessage` command line switch and the `$(MSBuildWarningsAsMessages)` MSBuild property successfully suppress `XAnnnn` warnings such as `XA4214`. The reason behind these changes is that I learned that the `msbuild /nowarn` option does *not* correspond to the `$(NoWarn)` MSBuild property. In fact, the `$(NoWarn)` property is not used at allby the MSBuild logger itself. It is instead passed into the [`<Csc/>` task in C# projects][0], the [`<Vbc/>` task in Visual Basic projects][1], and the [`MSBuildRestoreUtility` class][2] and [`<PackTask/>` task][3] in the NuGet package manager, allowing those tools to suppress the warnings internally, before MSBuild sees them. In the past, MSBuild did not provide a mechanism to suppress warnings via the MSBuild logger itself, so Xamarin.Android would have had to provide its own mechanism to suppress warnings internally. But as of [a few years ago][4], MSBuild now includes an `msbuild /nowarn` (aka `msbuild /warnasmessage`) option to control how the MSBuild logger itself suppresses warnings. The complication is that the meaning of the `$(NoWarn)` property was already well established by then, so instead of changing the semantics of that existing property, they [added a separate `$(MSBuildWarningsAsMessages)` property][5] to go along with the new command line option. Another little complication is that the [MSBuild command-line reference][6] does not yet mention the `msbuild /nowarn` or `msbuild /warnasmessage` options, and the [common MSBuild project properties documentation][7] does not yet mention the `$(MSBuildWarningsAsMessages)` property. The Visual Studio property pages UI doesn't currently include this property either. (The [**Build > Errors and warnings > Suppress warnings**][8] Visual Studio property pages setting corresponds to older the `$(NoWarn)` property instead.) Update the documentation to reference `msbuild /warnasmessage` and the `$(MSBuildWarningsAsMessages)` properties, instead of the (confusing) `msbuild /nowarn` option and (incorrect) `$(NoWarn)` prop. [0]: https://github.com/microsoft/msbuild/blob/v16.0.461.62831/src/Tasks/Microsoft.CSharp.CurrentVersion.targets#L259 [1]: https://github.com/microsoft/msbuild/blob/v16.0.461.62831/src/Tasks/Microsoft.VisualBasic.CurrentVersion.targets#L247 [2]: https://github.com/NuGet/NuGet.Client/blob/5.2.0.6045/src/NuGet.Core/NuGet.Commands/RestoreCommand/Utility/MSBuildRestoreUtility.cs#L606 [3]: https://github.com/NuGet/NuGet.Client/blob/5.2.0.6045/src/NuGet.Core/NuGet.Build.Tasks.Pack/NuGet.Build.Tasks.Pack.targets#L246 [4]: dotnet/msbuild@4287837 [5]: dotnet/msbuild@01f9915 [6]: https://docs.microsoft.com/visualstudio/msbuild/msbuild-command-line-reference?view=vs-2019 [7]: https://docs.microsoft.com/visualstudio/msbuild/common-msbuild-project-properties?view=vs-2019 [8]: https://docs.microsoft.com/en-us/visualstudio/ide/how-to-suppress-compiler-warnings?view=vs-2019#suppress-specific-warnings-for-visual-c-or-f
Steps to Reproduce
I know it might come with specific Nuget Packages installed but there is no way to identify which. Disabling them should work, though.
Expected Behavior
A way to disable them.
Version Information
XF: 3.1.0.583944 (I know there is a newer one but it breaks important things so can't be installed. Anyway, this has no bearing on this particular issue).
XA support libraries: 27.0.2.1
The text was updated successfully, but these errors were encountered: