unoplatform / uno

Open-source platform for building cross-platform native Mobile, Web, Desktop and Embedded apps quickly. Create rich, C#/XAML, single-codebase apps from any IDE. Hot Reload included! 90m+ NuGet Downloads!!
https://platform.uno
Apache License 2.0
9.06k stars 735 forks source link

Build error SA1633 when compiling an Uno Platform library. #9980

Closed Suriman closed 2 years ago

Suriman commented 2 years ago

Current behavior

In the library .csproj file, the 'TreatWarningsAsErrors' configuration is enabled and the 'XamlGeneratorAnalyzerSuppressions Include="StyleCop.CSharp.DocumentationRules-SA1633"' configure is also added, but the build error still appears.

Expected behavior

It shouldn't give any compile errors.

How to reproduce it (as minimally and precisely as possible)

Open the attached project and compile it. The SA1633 error should appear.

Workaround

Add the SA1633 to the NoWarn configuration.

Works on UWP/WinUI

No

Environment

Uno.UI / Uno.UI.WebAssembly / Uno.UI.Skia

NuGet package version(s)

Uno.WinUI 4.5.12

Affected platforms

iOS, Android, WebAssembly, macOS, Skia (WPF), Skia (GTK on Linux/macOS/Windows), Windows

IDE

Visual Studio 2022

IDE version

17.3.4

Relevant plugins

No response

Anything else we need to know?

See attached file! SA1633CompilationError2.zip

Youssef1313 commented 2 years ago

@Suriman Can you try <XamlGeneratorAnalyzerSuppressions Include="csharp-SA1633" />?

ADD-David-Antolin commented 2 years ago

The problem is in the generation of this file:

https://github.com/unoplatform/uno/blob/master/src/SourceGenerators/Uno.UI.SourceGenerators/BindableTypeProviders/BindableTypeProvidersGenerationTask.cs#L118

There are no supressions applied to that string so using does not make any difference.

GitHub
uno/BindableTypeProvidersGenerationTask.cs at master · unoplatform/uno
Build Mobile, Desktop and WebAssembly apps with C# and XAML. Today. Open source and professionally supported. - uno/BindableTypeProvidersGenerationTask.cs at master · unoplatform/uno
Youssef1313 commented 2 years ago

@ADD-David-Antolin It looks like we are missing a call for GenerateCSharpPragmaSupressions around these lines https://github.com/unoplatform/uno/blob/7cc2df180fb8b5833f3f6e05b50ac8d4ed4a8e99/src/SourceGenerators/Uno.UI.SourceGenerators/BindableTypeProviders/BindableTypeProvidersGenerationTask.cs#L173-L175

I can take a look once I finish some work. @jeromelaban Assign me this please.

Youssef1313 commented 2 years ago

There should be no need for the suppression actually. We don't mark the file as auto-generated which is wrong too. If it's marked as such, then SA1633 will not produce a diagnostic at all.

https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/6478404520b39f002ae0ce2d062f1474cf27b14f/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/FileHeaderAnalyzers.cs#L176

To be clear, there are two issues here:

ADD-David-Antolin commented 1 year ago

After updating to Uno 4.7 this error is happening again with your autogenerated class LocalizationResources.cs which it is not marked as autogenerated, so please reopen the issue.

Youssef1313 commented 1 year ago

@ADD-David-Antolin Thanks for raising this. I opened https://github.com/unoplatform/uno/pull/11291 to fix it.

jeromelaban commented 1 year ago

@ADD-David-Antolin make sure to open new issues even if the symptoms look similar. We generally do not reopen older issues as they are generally effectively different.