Skip to content
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

Make ResourceManager.BaseName work as documented. #75497

Merged
merged 4 commits into from
Nov 3, 2022

Conversation

madelson
Copy link
Contributor

This property is documented to return the "qualified namespace name and the root resource name of a resource file". However, previously when constructing a ResourceManager with a Type the BaseName property would instead return the name of the type without its namespace.

fix #74918

This property is documented to return the "qualified namespace name and
the root resource name of a resource file". However, previously when
constructing a ResourceManager with a Type the BaseName property would
instead return the name of the type without its namespace.

fix dotnet#74918
@ghost ghost added the community-contribution Indicates that the PR has been added by a community member label Sep 13, 2022
@ghost
Copy link

ghost commented Sep 13, 2022

Tagging subscribers to this area: @dotnet/area-system-resources
See info in area-owners.md if you want to be subscribed.

Issue Details

This property is documented to return the "qualified namespace name and the root resource name of a resource file". However, previously when constructing a ResourceManager with a Type the BaseName property would instead return the name of the type without its namespace.

fix #74918

Author: madelson
Assignees: -
Labels:

area-System.Resources

Milestone: -

@joperezr
Copy link
Member

Sorry for taking a while to look at this, thanks for the contribution!

Could you also please add more tests that ensure the right behavior of BaseName? For example, can you add one where the type doesn't have a namespace too?

Assert.Equal(typeWithoutNamespace.Name, manager.BaseName);

manager = new ResourceManager(typeof(List<string>));
Assert.Equal("System.Collections.Generic.List`1", manager.BaseName);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@joperezr any other test cases you'd like to see?

@buyaa-n
Copy link
Member

buyaa-n commented Oct 15, 2022

Thanks for the fix @madelson, but it might be not a bug needs a fix, see my comment on the issue for details, we might need to clarify the doc instead, I will dig into it more

Also there is existing test that specifically checking this scenario is failing on CI

 System.ComponentModel.Tests.ComponentResourceManagerTests.Ctor_Type(type: typeof(int)) [FAIL]
      Assert.Equal() Failure
                ↓ (pos 0)
      Expected: Int32
      Actual:   System.Int32
                ↑ (pos 0)
      Stack Trace:
        /_/src/libraries/System.ComponentModel.TypeConverter/tests/ComponentResourceManagerTests.cs(27,0): at System.ComponentModel.Tests.ComponentResourceManagerTests.Ctor_Type(Type type)
           at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
        /_/src/libraries/System.Private.CoreLib/src/System/Reflection/MethodInvoker.cs(69,0): at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)
  Finished:    System.ComponentModel.TypeConverter.Tests
=== TEST EXECUTION SUMMARY ===
   System.ComponentModel.TypeConverter.Tests  Total: 7825, Errors: 0, Failed: 1, Skipped: 0, Time: 32.183s

@madelson
Copy link
Contributor Author

Thanks for engaging @buyaa-n . I'll fix that test if we decide to proceed with this change.

@buyaa-n
Copy link
Member

buyaa-n commented Oct 28, 2022

Thanks for engaging @buyaa-n . I'll fix that test if we decide to proceed with this change.

Please do that so that we can see if any other test fails

@madelson
Copy link
Contributor Author

Please do that so that we can see if any other test fails

@buyaa-n pushed the fix!

Copy link
Member

@buyaa-n buyaa-n left a comment

Choose a reason for hiding this comment

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

Overall LGTM, thanks @madelson

@buyaa-n buyaa-n merged commit ce406f1 into dotnet:main Nov 3, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Dec 3, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.Resources community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ResourceManager has incorrect BaseName when constructed with a Type
4 participants