-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Removed duplicated Implementation of CultureAwareComparer #27099
Conversation
| { | ||
| throw new ArgumentException(SR.Argument_InvalidFlag, nameof(options)); | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see this in the .csproj:
https://github.com/Anipik/corefx/blob/c9a7d5c3e4fb4a1ef5897cb0c03440044922a986/src/System.Globalization.Extensions/src/System.Globalization.Extensions.csproj#L20-L21
and this should fail when built for netfx as the below overload doesn't exist there, but I see that build passed CI, and it looks like that's because we don't build this library for netfx:
https://github.com/Anipik/corefx/blob/c9a7d5c3e4fb4a1ef5897cb0c03440044922a986/src/System.Globalization.Extensions/src/Configurations.props#L5-L7
@tarekgh, is that just cruft that can be cleaned up?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tarekgh can you please tell which files need to be removed ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to delete the files
And then clean up the file
https://github.com/dotnet/corefx/blob/master/src/System.Globalization.Extensions/src/System.Globalization.Extensions.csproj
to remove any support for netfx there.
then we need to update the implementation in the file
to remove the CultureAwareComparer and modify the extension method there.
And we need to look at the file
I think we can remove it too and if any code using this file we can update it to use the new exposed API instead.
cc @weshaggard
tarekgh
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please modify the code as suggested in the other comment. Thanks
| <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Windows_NT-Release|AnyCPU'" /> | ||
| <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'uap-Windows_NT-Debug|AnyCPU'" /> | ||
| <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'uap-Windows_NT-Release|AnyCPU'" /> | ||
| <ItemGroup Condition="'$(TargetGroup)' == 'netfx'"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can delete all netfx conditions from this file.
| public override int GetHashCode() | ||
| { | ||
| return _compareInfo.GetHashCode() ^ ((int)_options & 0x7FFFFFFF); | ||
| return StringComparer.Create(CultureInfo.GetCultureInfo(compareInfo.Name), options); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It still does not feel right to me to make this method many times slower with this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tarekgh any other things that we can do ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It still does not feel right to me to make this method many times slower with this change.
I cannot think of any ready better solution rather than returning back the CultureAwareComparer here. the best we can do is to expose StringCompare.Create which takes a compare info. or we move the whole extension class to coelib
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move the whole extension class to coelib
That would be my pick.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Anipik could you please move this extension class to corelib? thanks a lot for your effort here.
@jkotas do you want to keep this PR open till we move the extension class to corelib? or we can proceed with this PR and have another PR to fix that?
Another thing for this PR, could you please clean up the ref folder too corefx\src\System.Globalization.Extensions\ref?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jkotas should we move to corelib in this PR or in a different PR ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Anipik You may start creating the coreclr PR from now.
| <Compile Include="System\Globalization\Extensions.cs" /> | ||
| <Compile Include="System\StringNormalizationExtensions.netfx.cs" /> | ||
| </ItemGroup> | ||
| <ItemGroup Condition="'$(TargetGroup)' != 'netfx'"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Condition="'$(TargetGroup)' != 'netfx'" [](start = 13, length = 39)
remove this condition
| <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Release|AnyCPU'" /> | ||
| <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'uap-Debug|AnyCPU'" /> | ||
| <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'uap-Release|AnyCPU'" /> | ||
| <ItemGroup Condition="'$(TargetGroup)' != 'netfx'"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not building for netfx. All conditions for netfx can be deleted too.
|
@dotnet-bot test this please |
|
@Anipik I assume you have tested it with your private changes in coreclr. right? |
| <ItemGroup> | ||
| <ProjectReference Include="..\..\System.Runtime\ref\System.Runtime.csproj" /> | ||
| <ProjectReference Include="..\..\System.Runtime.Extensions\ref\System.Runtime.Extensions.csproj" /> | ||
| <ProjectReference Include="..\..\System.Globalization\ref\System.Globalization.csproj" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can delete \..\System.Globalization\ref\System.Globalization.csproj line.
| <ProjectGuid>{2B96AA10-84C0-4927-8611-8D2474B990E8}</ProjectGuid> | ||
| <IsPartialFacadeAssembly>true</IsPartialFacadeAssembly> | ||
| <OmitResources Condition="'$(TargetGroup)' != 'netfx'">true</OmitResources> | ||
| <OmitResources>true</OmitResources> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Delete this line and also src\System.Globalization.Extensions\src\Resources\Strings.resx
| <Reference Include="System.Diagnostics.Tools" /> | ||
| <Reference Include="System.Resources.ResourceManager" /> | ||
| <Reference Include="System.Runtime" /> | ||
| <Reference Include="System.Runtime.Extensions" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you just need System.Runtime and System.Runtime.Extensions here.
|
@tarekgh I have tested them locally also and new version of coreclr has also been updated in corefx. |
|
@jkotas is it okay to merge it now ? |
Shared Coreclr Implementation PR - dotnet/coreclr#16334
Related to dotnet/corefx#395
Tests PR - #27051