ResxSourceGenerator: Format methods for string resources with parameters are not generated as "public" as it is with the properties #7535
Closed as duplicate of#7452
Description
Analyzer
Microsoft.CodeAnalysis.ResxSourceGenerator
Analyzer source
NuGet Package: Microsoft.CodeAnalysis.ResxSourceGenerator
Version: - 3.11.0-beta1.24605.2
Describe the bug
String resources containing parameters are generated as properties and additionally as format methods.
While the properties are generated with the access modifier public
, the format methods are generated with the access modifier internal
.
The format methods should also have the access modifier public
.
Steps To Reproduce
Add to the .resx
file a resource that contains at least one parameter.
e.g. Name: "PropertyNotValid"
, Value: "The property {propertyName} is not valid."
Expected behavior
This code should be generated:
/// <summary>The property {propertyName} is not valid.</summary>
public static string @PropertyNotValid => GetResourceString("PropertyNotValid")!;
/// <summary>The property {propertyName} is not valid.</summary>
public static string FormatPropertyNotValid(object? propertyName)
=> string.Format(Culture, GetResourceString("PropertyNotValid", new[] { "propertyName" }), propertyName);
Actual behavior
This code is currently generated:
/// <summary>The property {propertyName} is not valid.</summary>
public static string @PropertyNotValid => GetResourceString("PropertyNotValid")!;
/// <summary>The property {propertyName} is not valid.</summary>
internal static string FormatPropertyNotValid(object? propertyName)
=> string.Format(Culture, GetResourceString("PropertyNotValid", new[] { "propertyName" }), propertyName);
Metadata
Assignees
Labels
No labels