novotnyllc / MSBuildSdkExtras

Extra properties for MSBuild SDK projects
MIT License
347 stars 42 forks source link

Slight incompatibility with the old MSBuild way of doing resources #146

Open lcsondes opened 5 years ago

lcsondes commented 5 years ago

If you have an old WinForms project and add a space to your class name, it gets turned into an underscore so you would have for instance Test Class.cs containing Test_Class.

With this SDK (which saved our hides btw, it's amazing!) this behavior is mostly retained, however in the automatically-generated code's ResourceManager property getter there's a line that looks somewhat like this:

global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("MyNamespace.Test ClassResources", typeof(Test_ClassResources).Assembly);

And the space/underscore mismatch eventually leads to a runtime exception.

I did the trivial fix, which is to simply rename the class, but thought I'd report this as a small piece of incompatibility compared to old WinForms csprojs.

clairernovotny commented 5 years ago

Interesting… two questions

What are the exact repro steps?

This seems like a bug somewhere in VS though @davkean, do you know where this bug should go?

lcsondes commented 5 years ago

Hi, I'm using 2.1, most of my csprojs are using the Microsoft SDK, but the WinForms ones are using Extras.

Repro steps: make an old .NET framework Winforms project, add a new form that has a space in its name, manually edit the csproj to be an SDK-style csproj, build, run, observe exception. Here's a snippet of how my csproj looks.

<Project Sdk="MSBuild.Sdk.Extras">
  <ItemGroup>
    <Reference Include="System.Management" />
    <Reference Include="System.Windows.Forms" />
  </ItemGroup>
  <ItemGroup>
    <Compile Update="Test Class.Designer.cs">
      <DesignTime>True</DesignTime>
      <AutoGen>True</AutoGen>
      <DependentUpon>Test Class.resx</DependentUpon>
    </Compile>
  </ItemGroup>
  <ItemGroup>
    <EmbeddedResource Update="Test Class.resx">
      <Generator>ResXFileCodeGenerator</Generator>
      <LastGenOutput>Test Class.Designer.cs</LastGenOutput>
    </EmbeddedResource>
  </ItemGroup>
</Project>
clairernovotny commented 5 years ago

I'm going to close this as WinForms/WPF issues should be in the main SDK at this point for 3.0.