From ba57aaa346abc676becdf7e06539e0ad6acfdd40 Mon Sep 17 00:00:00 2001 From: uo1 Date: Tue, 23 Jul 2024 18:24:58 +0200 Subject: [PATCH 1/4] Update AbstractResxGenerator.cs - Changed the access modifier for format methods to "public" Changed the access modifier for format methods from "internal" to "public" like the properties are already. That makes it possible to access those methods from other assemblies too, when the class will be generated as public. --- .../AbstractResxGenerator.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.CodeAnalysis.ResxSourceGenerator/Microsoft.CodeAnalysis.ResxSourceGenerator/AbstractResxGenerator.cs b/src/Microsoft.CodeAnalysis.ResxSourceGenerator/Microsoft.CodeAnalysis.ResxSourceGenerator/AbstractResxGenerator.cs index 8cabf7b520..e6e93eaeaa 100644 --- a/src/Microsoft.CodeAnalysis.ResxSourceGenerator/Microsoft.CodeAnalysis.ResxSourceGenerator/AbstractResxGenerator.cs +++ b/src/Microsoft.CodeAnalysis.ResxSourceGenerator/Microsoft.CodeAnalysis.ResxSourceGenerator/AbstractResxGenerator.cs @@ -779,7 +779,7 @@ private static void SplitName(string fullName, out string? namespaceName, out st private static void RenderFormatMethod(string indent, Lang language, bool supportsNullable, StringBuilder strings, ResourceString resourceString) { - strings.AppendLine($"{indent}internal static string Format{resourceString.Name}({resourceString.GetMethodParameters(language, supportsNullable)})"); + strings.AppendLine($"{indent}public static string Format{resourceString.Name}({resourceString.GetMethodParameters(language, supportsNullable)})"); if (resourceString.UsingNamedArgs) { strings.AppendLine($@"{indent} => string.Format(Culture, GetResourceString(""{resourceString.Name}"", new[] {{ {resourceString.GetArgumentNames()} }}), {resourceString.GetArguments()});"); From 4306b5986e5864f1cf63f5a1fbbcf59e9924859f Mon Sep 17 00:00:00 2001 From: uo1 Date: Wed, 24 Jul 2024 15:06:43 +0200 Subject: [PATCH 2/4] Update Resources.Designer.cs replaced "internal" access modifier for format method with "public" --- .../Resources.Designer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.CodeAnalysis.ResxSourceGenerator/Microsoft.CodeAnalysis.ResxSourceGenerator.UnitTests/Resources/SingleString_EmitFormatMethodsCSharpAsync_0_True/Resources.Designer.cs b/src/Microsoft.CodeAnalysis.ResxSourceGenerator/Microsoft.CodeAnalysis.ResxSourceGenerator.UnitTests/Resources/SingleString_EmitFormatMethodsCSharpAsync_0_True/Resources.Designer.cs index b3919a15c4..8597201c7e 100644 --- a/src/Microsoft.CodeAnalysis.ResxSourceGenerator/Microsoft.CodeAnalysis.ResxSourceGenerator.UnitTests/Resources/SingleString_EmitFormatMethodsCSharpAsync_0_True/Resources.Designer.cs +++ b/src/Microsoft.CodeAnalysis.ResxSourceGenerator/Microsoft.CodeAnalysis.ResxSourceGenerator.UnitTests/Resources/SingleString_EmitFormatMethodsCSharpAsync_0_True/Resources.Designer.cs @@ -31,7 +31,7 @@ private static string GetResourceString(string resourceKey, string[]? formatterN /// value {0} public static string @Name => GetResourceString("Name")!; /// value {0} - internal static string FormatName(object? p0) + public static string FormatName(object? p0) => string.Format(Culture, GetResourceString("Name") ?? "", p0); From 830b4059281f6fdebb6672dc8fd83217958e4879 Mon Sep 17 00:00:00 2001 From: uo1 Date: Wed, 24 Jul 2024 15:07:07 +0200 Subject: [PATCH 3/4] Update Resources.Designer.cs replaced "internal" access modifier for format method with "public" --- .../Resources.Designer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.CodeAnalysis.ResxSourceGenerator/Microsoft.CodeAnalysis.ResxSourceGenerator.UnitTests/Resources/SingleString_EmitFormatMethodsCSharpAsync_replacement_True/Resources.Designer.cs b/src/Microsoft.CodeAnalysis.ResxSourceGenerator/Microsoft.CodeAnalysis.ResxSourceGenerator.UnitTests/Resources/SingleString_EmitFormatMethodsCSharpAsync_replacement_True/Resources.Designer.cs index fa77240ec6..294e474005 100644 --- a/src/Microsoft.CodeAnalysis.ResxSourceGenerator/Microsoft.CodeAnalysis.ResxSourceGenerator.UnitTests/Resources/SingleString_EmitFormatMethodsCSharpAsync_replacement_True/Resources.Designer.cs +++ b/src/Microsoft.CodeAnalysis.ResxSourceGenerator/Microsoft.CodeAnalysis.ResxSourceGenerator.UnitTests/Resources/SingleString_EmitFormatMethodsCSharpAsync_replacement_True/Resources.Designer.cs @@ -31,7 +31,7 @@ private static string GetResourceString(string resourceKey, string[]? formatterN /// value {replacement} public static string @Name => GetResourceString("Name")!; /// value {replacement} - internal static string FormatName(object? replacement) + public static string FormatName(object? replacement) => string.Format(Culture, GetResourceString("Name", new[] { "replacement" }), replacement); From b08a0c58bbe14c792d9fe3bdb11ae021da52941a Mon Sep 17 00:00:00 2001 From: uo1 Date: Wed, 24 Jul 2024 15:07:29 +0200 Subject: [PATCH 4/4] Update Resources.Designer.cs replaced "internal" access modifier for format method with "public" --- .../Resources.Designer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.CodeAnalysis.ResxSourceGenerator/Microsoft.CodeAnalysis.ResxSourceGenerator.UnitTests/Resources/SingleString_EmitFormatMethodsCSharpAsync_x_True/Resources.Designer.cs b/src/Microsoft.CodeAnalysis.ResxSourceGenerator/Microsoft.CodeAnalysis.ResxSourceGenerator.UnitTests/Resources/SingleString_EmitFormatMethodsCSharpAsync_x_True/Resources.Designer.cs index fe057e9cbf..e29c06e76d 100644 --- a/src/Microsoft.CodeAnalysis.ResxSourceGenerator/Microsoft.CodeAnalysis.ResxSourceGenerator.UnitTests/Resources/SingleString_EmitFormatMethodsCSharpAsync_x_True/Resources.Designer.cs +++ b/src/Microsoft.CodeAnalysis.ResxSourceGenerator/Microsoft.CodeAnalysis.ResxSourceGenerator.UnitTests/Resources/SingleString_EmitFormatMethodsCSharpAsync_x_True/Resources.Designer.cs @@ -31,7 +31,7 @@ private static string GetResourceString(string resourceKey, string[]? formatterN /// value {x} public static string @Name => GetResourceString("Name")!; /// value {x} - internal static string FormatName(object? x) + public static string FormatName(object? x) => string.Format(Culture, GetResourceString("Name", new[] { "x" }), x);