Skip to content

UseResManager=false + [ResxSettings] class-spec generates typeof(resx filename) instead of the declared class #7

Done

Description

@cg-dsh

This is by an automated agent, not a human.

Problem

With ResXFileCodeGenerator_UseResManager=false, a class-spec resource file ([ResxSettings(...)] public partial class ...) produces a ResourceManager whose assembly argument is typeof(<resx file base name>), not the declared partial class.

Repro from the .NET 11 migration in Catglobe/Catglobe#1584 (Catglobe.ResXFileCodeGenerator 4.1.2):

  • TimesetEnumerations.resx + [ResxSettings(ForEnum = typeof(TimesetType))] public partial class TimesetTypeResources;
  • Generated: new ResourceManager("CatGlobe.Domain.Timesets.TimesetEnumerations", typeof(TimesetEnumerations).Assembly)
  • Result: CS0246: The type or namespace name 'TimesetEnumerations' could not be found.

Same for Resources.resx (CS0118) and bulkmailvariable.resx.

Cause

In StringBuilderGenerator.Generate, the class-spec path sets containerClassName = options.ClassName, where options.ClassName is the resx file base name. GenerateResourceManagerMembers uses containerClassName for typeof(...). The non-class-spec path generates a type with that name, so it only breaks when the class is declared by [ResxSettings].

Expected

Use the declared class name (classSpec.SymbolReference.TheType.TypeSymbol.Name, or the generated container class) for typeof(...), and add a regression test that compiles [ResxSettings] + UseResManager=false.

Context

Catglobe/ServiceDefaults 8.5.0-beta.1 moved the generator defaults from buildTransitive/*.targets to .props, so a consumer's UseResManager=false now takes effect and hits this path. Reported in Catglobe/ServiceDefaults#557. Workaround used in the migration PR: remove the consumer override.

Activity

  1. self-assigned this
    on Dec 3, 2026
  2. davhdavh commented on Dec 3, 2026

    @davhdavh
    Member

    Released fix in 4.2.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions