dotnet / winforms

Windows Forms is a .NET UI framework for building Windows desktop applications.
MIT License
4.36k stars 965 forks source link

Let's change the C# templates to include the Project-level app settings. #9931

Open KlausLoeffelmann opened 12 months ago

KlausLoeffelmann commented 12 months ago

Project-level Application Settings are cool, but a Nightmare in discoverability. When I need to change values, I always have to look them up via the provided link in program.cs, because I cannot remember the exact syntax in .csproj. So, for that reason, I'd like to include them in the .csproj so they are setting their default values. Or, at least, I want them there, but commented out.

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>WinExe</OutputType>
    <TargetFramework>net6.0-windows</TargetFramework>
    <Nullable>enable</Nullable>
    <UseWindowsForms>true</UseWindowsForms>
    <ImplicitUsings>enable</ImplicitUsings>

    <!--WinForms Application settings:-->
    <ApplicationVisualStyles>true</ApplicationVisualStyles>
    <ApplicationDefaultFont>Segoe UI, 9pt</ApplicationDefaultFont>
    <ApplicationHighDpiMode>SystemAware</ApplicationHighDpiMode>
    <ApplicationUseCompatibleTextRendering>True</ApplicationUseCompatibleTextRendering>
  </PropertyGroup>

</Project>

Suggesting this for .NET 9, please comment, up- or down-vote!

image

tbolon commented 12 months ago

Isn't the default behavior to also include these properties in the Properties screen of the project? From the project system?

There are other MSBuild properties that I don't remember easily and I took the habit to set an explicit value in the Properties page then open the csproj XML to read the name of the element.