Skip to content

Workaround for build-failures caused by ResXCodeFileGenerator regression in dotnet-wpf-int #1495

Closed

Description

@vatsan-madhavan

Related: #1492

WPF uses ResXFileCodeGenerator it its builds. We have a resx with entries like this (Documents.resx)

  <data name="Invalid_35x35" type="System.Resources.ResXFileRef, System.Windows.Forms">
    <value>Invalid_35x35.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
  </data>

It generates getters that should look like this:

        internal static System.Drawing.Bitmap Invalid_35x35 {
            get {
                object obj = ResourceManager.GetObject("Invalid_35x35", resourceCulture);
                return ((System.DrawingBitmap)(obj));
            }
        }

Suddenly, as of some recent VS build, ResXFileCodeGenerator is starting to emit files with getters that are instead like this (not the return type – they are plain object).

        /// <summary>
        ///   Looks up a localized resource of type System.Object similar to Microsoft.Build.Tasks.ResourceHandling.LiveObjectResource.
        /// </summary>
        internal static object Invalid_35x35 {
            get {
                object obj = ResourceManager.GetObject("Invalid_35x35", resourceCulture);
                return ((object)(obj));
            }
        }

Here is a standalone repro that illustrates the problem. Build with commandline msbuild (not dotnet, use msbuild, VS version dev16.3p2 29128.8.master, Int Preview).

After building, open obj\Debug\netcoreapp3.0\MS.Internal.Documents.Resources.cs and you can see getters that return object instead of specifc types.

resx-codegen-issue.zip

WPF uses ResXFileCodeGenerator it its builds. We have a resx with entries like this (Documents.resx)

  <data name="Invalid_35x35" type="System.Resources.ResXFileRef, System.Windows.Forms">
    <value>Invalid_35x35.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
  </data>

It generates getters that should look like this:

        internal static System.Drawing.Bitmap Invalid_35x35 {
            get {
                object obj = ResourceManager.GetObject("Invalid_35x35", resourceCulture);
                return ((System.DrawingBitmap)(obj));
            }
        }

Suddenly, as of some recent VS build, ResXFileCodeGenerator is starting to emit files with getters that are instead like this (not the return type – they are plain object).

        /// <summary>
        ///   Looks up a localized resource of type System.Object similar to Microsoft.Build.Tasks.ResourceHandling.LiveObjectResource.
        /// </summary>
        internal static object Invalid_35x35 {
            get {
                object obj = ResourceManager.GetObject("Invalid_35x35", resourceCulture);
                return ((object)(obj));
            }
        }

Here is a standalone repro that illustrates the problem. Build with commandline msbuild (not dotnet, use msbuild, VS version dev16.3p2 29128.8.master, Int Preview).

After building, open obj\Debug\netcoreapp3.0\MS.Internal.Documents.Resources.cs and you can see getters that return object instead of specifc types.

resx-codegen-issue.zip

Activity

  1. added this to the 3.0 milestone on Aug 1, 2019
  2. vatsan-madhavan commented on Aug 1, 2019

    @vatsan-madhavan
    MemberAuthor

    For now,

    • Fixup Documents.resx that's part of PresenationUI with updated versions
    • Bug in ResXFileCodeGenerator is failing to correctly specify types for resources, and they are being returned as object.
      • Cast them correctly based on information present in Resources\Documents.resx. This is a temporary workaround and we need a real fix in the generator.
      • Once the fix is in, this workaround should be removed.
  3. added
    tell-mode
    on Aug 1, 2019
  4. vatsan-madhavan commented on Aug 1, 2019

    @vatsan-madhavan
    MemberAuthor
  5. ghost locked as resolved and limited conversation to collaborators on Apr 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

tell-mode

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions