Skip to content

Create format string based on untruncated value#3245

Merged
JunTaoLuo merged 2 commits intomasterfrom
johluo/fix-resx
Jul 10, 2019
Merged

Create format string based on untruncated value#3245
JunTaoLuo merged 2 commits intomasterfrom
johluo/fix-resx

Conversation

@JunTaoLuo
Copy link
Copy Markdown

Addresses #3244.

Instead of the truncated value used for XML docs
/// <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>
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 JunTaoLuo requested a review from tmat July 9, 2019 15:38
@JunTaoLuo
Copy link
Copy Markdown
Author

cc @markwilkie @nguerrera @tmat who can review this?

RenderDocComment(language, memberIndent, strings, value);
RenderDocComment(language, memberIndent, strings, docCommentString);

string identifier = IsLetterChar(CharUnicodeInfo.GetUnicodeCategory(name[0])) ? name : "_" + name;
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tmat what did you mean by VB? It doesn't seem to use anything other than defaultValue.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Copy Markdown
Member

@tmat tmat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants