-
Notifications
You must be signed in to change notification settings - Fork 991
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
Implement Windows Forms application configuration and bootstrap #5035
Conversation
This comment has been minimized.
This comment has been minimized.
2cc240a
to
c06b8f2
Compare
src/System.Windows.Forms.Analyzers/src/System.Windows.Forms.Analyzers.csproj
Show resolved
Hide resolved
c06b8f2
to
d02e4b9
Compare
...alyzers.CSharp/src/System/Windows/Forms/Generators/ApplicationConfigurationSyntaxReceiver.cs
Outdated
Show resolved
Hide resolved
src/System.Windows.Forms.Analyzers/src/DiagnosticDescriptors.cs
Outdated
Show resolved
Hide resolved
...ms.Analyzers.CSharp/src/System/Windows/Forms/Generators/ApplicationConfigurationGenerator.cs
Outdated
Show resolved
Hide resolved
...stem.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/Generators/ProjectFileReader.cs
Outdated
Show resolved
Hide resolved
...stem.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/Generators/ProjectFileReader.cs
Outdated
Show resolved
Hide resolved
...stem.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/Generators/ProjectFileReader.cs
Outdated
Show resolved
Hide resolved
...stem.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/Generators/ProjectFileReader.cs
Outdated
Show resolved
Hide resolved
...stem.Windows.Forms.Analyzers.CSharp/src/System/Windows/Forms/Generators/ProjectFileReader.cs
Outdated
Show resolved
Hide resolved
src/System.Windows.Forms.Analyzers/src/DiagnosticDescriptors.cs
Outdated
Show resolved
Hide resolved
src/System.Windows.Forms.Analyzers.CSharp/tests/UnitTests/StringText.cs
Outdated
Show resolved
Hide resolved
pkg/Microsoft.Private.Winforms/Microsoft.Private.Winforms.csproj
Outdated
Show resolved
Hide resolved
8fbf2ae
to
4d2b7ea
Compare
...ms.Analyzers.CSharp/src/System/Windows/Forms/Generators/ApplicationConfigurationGenerator.cs
Show resolved
Hide resolved
edc94bc
to
c79efb4
Compare
bf16a7a
to
d003a72
Compare
168c42a
to
30fb427
Compare
Add a C# source generator that emits application bootstrap as described in https://github.com/dotnet/designs/blob/main/accepted/2021/winforms/streamline-application-bootstrap.md for the following properties: * ApplicationVisualStyles * ApplicationDefaultFont * ApplicationHighDpiMode * ApplicationUseCompatibleTextRendering For top level statements the bootstrap also emits code to set STA mode. A build will fail if any of the properties contain invalid or otherwise incorrect values. FontConverter is not available in netstandard 2.0, to bridge the gap FontConverter logic has been partially copied from the corresponding .NET runtime implementation to facilitate the comparable behaviour. The only missing gap is parsing of FontFamily (which requires GDI+ calls), which means that if a supplied font descriptor contains an invalid font name it will cause an app to crash. This however is a desired behaviour.
4a1a2ce
to
e064c54
Compare
Add analyzers for C# and VB projects that check whether a user project contains a manifest file, which includes dpi configurations. If such manifest is detected the user is advised to use Application.SetHighDpiMode() API instead.
I've done quite an extensive testing of building and packaging dotnet/winforms, dotnet/wpf and dotnet/windowsdesktop locally, then had the same flow simulated via the internal CI. I'm reasonably comfortable that this is working as intended. I'm planning to merge this and a follow up PR in dotnet/windowsdesktop in coming days. There're no changes required to dotnet/wpf (that builds the Windows Desktop SDK). |
e064c54
to
329e453
Compare
@KlausLoeffelmann @KathleenDollard the analyzers also work for VB apps If necessary you can update the wording here winforms/src/System.Windows.Forms.Analyzers/src/Resources/SR.resx Lines 67 to 69 in 6515f5f
|
Sweet |
Relates to dotnet#5035 Relates to dotnet#5071
Relates to dotnet#5035 Relates to dotnet#5071
Implements dotnet/designs#223
Resolves #4909
Pre-req for dotnet/windowsdesktop#1693
Pre-req for https://github.com/dotnet/winforms-designer/issues/3192
Proposed changes
dpiAware
configurations in app.manifestTest methodology
Manual packaging tests for the analyzer props/targets references in the Microsoft.NET.Sdk.WindowsDesktop, see Ingest and import Windows Forms analyzer props wpf#4605dotnet new winforms
Microsoft Reviewers: Open in CodeFlow