project-system icon indicating copy to clipboard operation
project-system copied to clipboard

RESX code generation does not respect <LogicalName>

Open davkean opened this issue 8 years ago • 5 comments

The RESX code generation does not respect the <LogicalName> metadata item on a <EmbeddedResource/> item.

For example, the following:

    <EmbeddedResource Include="Resources\Designer.resx">
      <LogicalName>Microsoft.VisualStudio.Editors.Designer.resources</LogicalName>
      <SubType>Designer</SubType>
      <CustomToolNamespace>My.Resources</CustomToolNamespace>
      <Generator>ResXFileCodeGenerator</Generator>
      <LastGenOutput>Designer.Designer.vb</LastGenOutput>
    </EmbeddedResource>

Should result in code gen with:

        Friend Shared ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager
            Get
                If Object.ReferenceEquals(resourceMan, Nothing) Then
                    Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("Microsoft.VisualStudio.Editors.Designer", GetType(Designer).Assembly)
                    resourceMan = temp
                End If
                Return resourceMan
            End Get
        End Property

but actually results in:

        Friend Shared ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager
            Get
                If Object.ReferenceEquals(resourceMan, Nothing) Then
                    Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("Designer", GetType(Designer).Assembly)
                    resourceMan = temp
                End If
                Return resourceMan
            End Get
        End Property

We hit this fixing: https://github.com/dotnet/roslyn-project-system/issues/1056

davkean avatar Dec 30 '16 00:12 davkean

I believe this occurs because we don't return the correct value for __VSHPROPID.VSHPROPID_DefaultNamespace for the .resx file item.

http://index/?rightProject=Microsoft.VisualStudio.Design&file=Serialization%5CResXFileCodeGenerator.cs&line=201

drewnoakes avatar Jun 26 '20 01:06 drewnoakes

Looked at this with Dave and concluded that ResXFileCodeGenerator needs extra logic to consume the logical name for the item, and decided to do this via the browse object.

drewnoakes avatar Jun 26 '20 02:06 drewnoakes

https://devdiv.visualstudio.com/DevDiv/_git/VS/pullrequest/257392?_a=files

drewnoakes avatar Jun 26 '20 03:06 drewnoakes

This is the PR: https://devdiv.visualstudio.com/DevDiv/_git/VS/pullrequest/262111.

davkean avatar Jul 21 '20 01:07 davkean

Is there a syntax for saying that the resource is a webresource (aka add the WebResourceAttribute to the metadata for the resulting assembly)

jrmoreno1 avatar Jul 07 '22 17:07 jrmoreno1