Version Used: Microsoft.CodeAnalysis.ResxSourceGenerator 5.0.0-1.25277.114
Steps to Reproduce:
See resxrepro.zip for a minimal repro.
Or, just do this:
- Set
ClassName metadata on an EmbeddedResource item for a Strings.resx file to some other namespace.classname value.
<ItemGroup>
<EmbeddedResource Update="Strings.resx" ClassName="AdjustedNS.AdjustedName" />
</ItemGroup>
- Look at the generated Strings.Designer.cs file.
Expected Behavior:
I expect to see only AdjustedNS as the namespace and only AdjustedName as the type name in the emitted coce.
Actual Behavior:
I see both the default and the adjusted namespace and name for the class:
// <auto-generated/>
#nullable enable
using System.Reflection;
namespace resxrepro
{
internal static class Strings { }
}
namespace AdjustedNS
{
internal static partial class AdjustedName
{
private static global::System.Resources.ResourceManager? s_resourceManager;
public static global::System.Resources.ResourceManager ResourceManager => s_resourceManager ?? (s_resourceManager = new global::System.Resources.ResourceManager(typeof(resxrepro.Strings)));
public static global::System.Globalization.CultureInfo? Culture { get; set; }
[global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
[return: global::System.Diagnostics.CodeAnalysis.NotNullIfNotNull("defaultValue")]
internal static string? GetResourceString(string resourceKey, string? defaultValue = null) => ResourceManager.GetString(resourceKey, Culture) ?? defaultValue;
/// <summary>The index for the account. Must be a non-negative number.</summary>
public static string @AccountIndexOptionDescription => GetResourceString("AccountIndexOptionDescription")!;
}
}
This breaks our builds, because resxrepro should never be a namespace, since it already appears as a type in the same context, causing C# to deal with compile errors when we reference the type that also now appears as a namespace.
This namespace/type changing works fine in the old resx design-time generated, designer.cs file approach.
As such, this is an adoption blocker of the new resx source generator.
Version Used: Microsoft.CodeAnalysis.ResxSourceGenerator 5.0.0-1.25277.114
Steps to Reproduce:
See resxrepro.zip for a minimal repro.
Or, just do this:
ClassNamemetadata on anEmbeddedResourceitem for a Strings.resx file to some other namespace.classname value.Expected Behavior:
I expect to see only
AdjustedNSas the namespace and onlyAdjustedNameas the type name in the emitted coce.Actual Behavior:
I see both the default and the adjusted namespace and name for the class:
This breaks our builds, because
resxreproshould never be a namespace, since it already appears as a type in the same context, causing C# to deal with compile errors when we reference the type that also now appears as a namespace.This namespace/type changing works fine in the old resx design-time generated, designer.cs file approach.
As such, this is an adoption blocker of the new resx source generator.