Skip to content

Separate GetResourceString method with defaultString value. #51073

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 13, 2021

Conversation

marek-safar
Copy link
Contributor

It's not used in Release build and it injects ununsed null value to every callsite

It's not used in Release build and it injects ununsed null value to every callsite
@ghost
Copy link

ghost commented Apr 11, 2021

I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly one area label.

@stephentoub
Copy link
Member

It's not used in Release build

Is this true? e.g.

internal TimersDescriptionAttribute(string description, string defaultValue) : base(SR.GetResourceString(description, defaultValue)) { }

string word_At = SR.GetResourceString(nameof(SR.Word_At), defaultString: "at");

Copy link
Member

@stephentoub stephentoub left a comment

Choose a reason for hiding this comment

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

That said, splitting it seems fine. Most assemblies don't need the latter.

@@ -23,11 +23,11 @@ internal static partial class SR
false;
#endif

internal static string GetResourceString(string resourceKey, string? defaultString = null)
internal static string GetResourceString(string resourceKey)
Copy link
Member

Choose a reason for hiding this comment

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

This creates a difference from its .vb counterpart.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Does it matter? The only place where it's used is in archived Microsoft.VisualBasic.Core library

Copy link
Member

Choose a reason for hiding this comment

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

I don't know that it matters, but I wanted to call it out.
cc: @tarekgh

Copy link
Member

Choose a reason for hiding this comment

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

The only place where it's used is in archived Microsoft.VisualBasic.Core library

that is right. if this change is not affecting Microsoft.VisualBasic.Core, it should be ok. But should we just keep C# and VB match for consistency?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd rather not touch Microsoft.VisualBasic.Core code and I don't think the consistency matters here.

@marek-safar
Copy link
Contributor Author

Is this true? e.g.

runtime/src/libraries/System.ComponentModel.TypeConverter/src/System/Timers/TimersDescriptionAttribute.cs

The value is always null. I intentionally didn't want to mix the clean up with PR

runtime/src/libraries/System.Private.CoreLib/src/System/Diagnostics/StackTrace.cs

That's the only case

runtime/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Errors/ErrorFacts.cs

The assembly is archived so I didn't update the code (it's not worth it)

The only cases where it's really used in Release build are StackTrace.cs and System.ComponentModel.Annotations library if that's what you were asking for.

@stephentoub
Copy link
Member

if that's what you were asking for

I was mainly questioning the assertion.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants