Create format string based on untruncated value#3245
Merged
Conversation
Instead of the truncated value used for XML docs
JunTaoLuo
commented
Jul 8, 2019
| /// <summary>The really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really long format st ...</summary> | ||
| internal static string StringWithNumberedArgs => GetResourceString("StringWithNumberedArgs"); | ||
| /// <summary>The format string '{0}' has numbered {1} parameter {2}.</summary> | ||
| /// <summary>The really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really long format st ...</summary> |
Author
There was a problem hiding this comment.
FYI without the fix, this test would fail:
[xUnit.net 00:00:00.80] Microsoft.DotNet.Arcade.Sdk.Tests.GenerateResxSourceTests.GeneratesCSharp(emitFormatMethods: True, asConstants: False, omitGetResourceString: False, expectedFileName: "TestStrings.EmitFormatMethods.cs.txt") [FAIL]
X Microsoft.DotNet.Arcade.Sdk.Tests.GenerateResxSourceTests.GeneratesCSharp(emitFormatMethods: True, asConstants: False, omitGetResourceString: False, expectedFileName: "TestStrings.EmitFormatMethods.cs.txt") [15ms]
Error Message:
Assert.Equal() Failure
↓ (pos 2150)
Expected: ··· /// <summary>The really really really really really re···
Actual: ··· /// <summary>No arguments for this one.</summary>\r\n ···
↑ (pos 2150)
Stack Trace:
at Microsoft.DotNet.Arcade.Sdk.Tests.GenerateResxSourceTests.GeneratesCSharp(Boolean emitFormatMethods, Boolean asConstants, Boolean omitGetResourceString, String expectedFileName) in C:\gh\arcade\src\Microsoft.DotNet.Arcade.Sdk.Tests\GenerateResxSourceTests.cs:line 60
Standard Output Messages:
// <auto-generated>
using System.Reflection;
namespace Microsoft.DotNet
{
internal static partial class TestStrings
{
private static global::System.Resources.ResourceManager s_resourceManager;
internal static global::System.Resources.ResourceManager ResourceManager => s_resourceManager ?? (s_resourceManager = new global::System.Resources.ResourceManager(typeof(TestStrings)));
internal static global::System.Globalization.CultureInfo Culture { get; set; }
[global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
internal static string GetResourceString(string resourceKey, string defaultValue = null) => ResourceManager.GetString(resourceKey, Culture);
private static string GetResourceString(string resourceKey, string[] formatterNames)
{
var value = GetResourceString(resourceKey);
if (formatterNames != null)
{
for (var i = 0; i < formatterNames.Length; i++)
{
value = value.Replace("{" + formatterNames[i] + "}", "{" + i + "}");
}
}
return value;
}
/// <summary>The format '{noun}' has {adjective} parameters.</summary>
internal static string StringWithNamedArgs => GetResourceString("StringWithNamedArgs");
/// <summary>The format '{noun}' has {adjective} parameters.</summary>
internal static string FormatStringWithNamedArgs(object noun, object adjective)
=> string.Format(Culture, GetResourceString("StringWithNamedArgs", new [] { "noun", "adjective" }), noun, adjective);
/// <summary>The really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really long format st ...</summary>
internal static string StringWithNumberedArgs => GetResourceString("StringWithNumberedArgs");
/// <summary>No arguments for this one.</summary>
internal static string StringWithoutArgs => GetResourceString("StringWithoutArgs");
}
}
JunTaoLuo
commented
Jul 8, 2019
Author
|
cc @markwilkie @nguerrera @tmat who can review this? |
JunTaoLuo
commented
Jul 10, 2019
| RenderDocComment(language, memberIndent, strings, value); | ||
| RenderDocComment(language, memberIndent, strings, docCommentString); | ||
|
|
||
| string identifier = IsLetterChar(CharUnicodeInfo.GetUnicodeCategory(name[0])) ? name : "_" + name; |
Author
There was a problem hiding this comment.
@tmat what did you mean by VB? It doesn't seem to use anything other than defaultValue.
Member
There was a problem hiding this comment.
VB specific code uses defaultValue, which is derived from value. But now that we don't change value, it's all good.
In reply to: 301851823 [](ancestors = 301851823)
This was referenced Jul 28, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses #3244.