Project-system: ResXFileCodeGenerator does not emit GetTypeInfo() as required for netstandard, netcoreapp 1.x project

Created on 14 Nov 2016  路  12Comments  路  Source: dotnet/project-system

Given the following in a project targeting netcoreapp or netstandard via our SDK with:

  <ItemGroup>
    <EmbeddedResource Include="Strings.resx">
      <Generator>ResXFileCodeGenerator</Generator>
      <LastGenOutput>Strings.Designer.cs</LastGenOutput>
    </EmbeddedResource>
  </ItemGroup>

The emitted C# code has typeof(Strings).Assembly, where it should be typeof(Strings).GetTypeInfo().Assembly

Note that we have discussed moving this generation to the build and out of VS, with the code being stored only in intermediate directory. This would also help address the bad interaction with globbing tracked by https://github.com/dotnet/sdk/issues/94

However, addressing it that way will take significant effort to get the code generation happening cross-platform during a build. This is the right direction, but I think we should unblock the old VS generation mechanism in parallel to unblock our own dogfooding scenario and those of other early adopters.

@333fred @srivatsn @dotnet/project-system

Bug

All 12 comments

@333fred Makes sense. Can you test this out when you fix #686?

Yep, will do.

I've figured out the root cause of #686, and it's not related to this. @davkean has some ideas what we should be doing for this one.

Got a fix for this:

image

Fixed by #1148

Still getting this despite the supposed fix being long merged...for me, it happens because I'm multitargeting both net46 and netstandard1.3.

for reproducing this bug:

  1. create new solution (Blank Forms App)
  2. set Target Framework of 'core' project from .NET Protable to .NET Standard Platform
  3. add new .resx File (VS generates automatically designer.cs file)
  4. error occurs in designer.cs ('Type' does not contain a definition for 'Assembly' and no extension method 'Assembly' accepting a first argument of type 'Type' could be found (are you missing a using directive or an assembly reference?) (CS1061))

@kentcb Reopening for multitargeting case. Thanks for reporting that detail. Cc @davkean

@dephiloper What do you mean by Blank Forms app? Windows Forms? You shouldn't be able to just retarget that to .NET Standard. Can you share the .csproj that results from your steps?

Sorry, #1519 already covers the multitargeting case.

@nguerrera sorry for not mentioning my problem was focusing on app development when creating an blank (xamarin) forms app

@nguerrera I still have an issue with multi-targeting net2.0 and netstandard1.3 - the code generated for one framework is incompatible with another.

I can work around it by introducing a couple of shims, one for the extension attribute the other to return Type under net2.0/net3,5 but I think the resource generator should be emitting conditional code

Was this page helpful?
0 / 5 - 0 ratings