Skip to content

GenerateResource does not fail when converting binary .resx resources to .txt resources #308

Closed

Description

@cdmihai

On the full framework, if a .resx data element points to a path and there's a type specified to read that file, the conversion of the .resx resource to a .txt resource is impossible and the tasks logs an error (since .txt resources cannot have binary values).

However, the .net core behaviour is to write the file path to the .txt.

This happens because the full framework uses a special xml reader, ResXResourceReader , that reads a path in the .resx file directly to its specified .net object. However this special xml reader is not available in .net core, so a normal xml reader is used instead, which just reads the text file name.

Tests that capture failure:

  • GenerateResource_Tests.UnsupportedTextType, InvalidReference, FailedResourceReader

Other implications

  • .resx binary resources with specified .net types don't work.

@dsplaisted Should we copy the ResXResourceReader type to the msbuild codebase? If we try to mimic its behaviour, we end up re-implementing it.

Activity

  1. cdmihai commented on Oct 21, 2015

    @cdmihai
    ContributorAuthor

    I looked at all the FEATURE_RESX_RESOURCE_READER instances, and it modified the contract in the following manner:

    Read from .resx - allowed, but values are cast to string, not interpreted. Therefore binary resources referenced via a file are not loaded into their .net objects. Either the contract for resgen.exe and .resx format is different for .net core, or this is a bug
    Read from .resource - not allowed

    Write to .resx - not allowed
    Write to .resource - yes, but by coercing values to string

  2. rainersigwald commented on Jul 13, 2017

    @rainersigwald
    Member

    This is fixable now that the ResX types are available in .NET Core 2, but MSBuild can't take advantage of that yet.

  3. added this to the MSBuild 16.0 milestone on Dec 14, 2018
  4. added
    Area: Tasks
    on Dec 14, 2018
  5. added a commit that references this issue on Jan 23, 2019
    2ff540c
  6. added
    Area: Task: GenerateResource
    on Mar 13, 2019
  7. self-assigned this
    on Oct 7, 2019
  8. added a commit that references this issue on Oct 18, 2019
    9aa42bb
  9. added a commit that references this issue on Oct 24, 2019
    455f5be
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

.NET CoreArea: Task: GenerateResourceArea: Tasksbugtriaged

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions