Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Globalization merge#9835

Merged
tarekgh merged 8 commits into
dotnet:masterfrom
tarekgh:GlobalizationMerge
Mar 1, 2017
Merged

Globalization merge#9835
tarekgh merged 8 commits into
dotnet:masterfrom
tarekgh:GlobalizationMerge

Conversation

@tarekgh
Copy link
Copy Markdown
Member

@tarekgh tarekgh commented Feb 27, 2017

This change is merging the globalization code used for Linux and Windows. here Is come notes about this merge:

  • Mainly picked most of the code from the corefx folder as it is well formatted and cleaned up before and then tweaked the implementation to work on Windows
  • Tries to reduce the dependencies from Globalization code on the VM. this will give flexibility to work on the code without worrying the VM
  • Provided the missing implementation as I removed many internal calls to the VM. This also help in having .Net Native have complete implementation for .net standard 2.0
  • We may need to have some small tweaks when merging this globalization code to corert
  • We'l need to do some clean up for the code which not used anymore in the VM

@tarekgh
Copy link
Copy Markdown
Member Author

tarekgh commented Feb 27, 2017

@jkotas @ellismg could you please help taking a look?

cc @danmosemsft

<MscorlibSources Include="$(BclSourcesRoot)\System\Globalization\JapaneseLunisolarCalendar.cs" />
<MscorlibSources Include="$(BclSourcesRoot)\System\Globalization\JulianCalendar.cs" />
<MscorlibSources Include="$(BclSourcesRoot)\System\Globalization\KoreanCalendar.cs" />
<MscorlibSources Include="$(BclSourcesRoot)\System\Globalization\KoreanLunisolarCalendar.cs" />
Copy link
Copy Markdown
Member

@jkotas jkotas Feb 27, 2017

Choose a reason for hiding this comment

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

Shouldn't we be rather keeping the version of System\Globalization* files from under corefx? The copy under corefx is better formatted and factored.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

that is what I have done. I copied the files from corefx to BclSourceRoot\S\G and deleted all files in corefx\S\G folder. but the code we have now is what we had in corefx folder.

I am just thinking later we should get rid of the whole corefx folder

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.

I see a bunch of diffs between current corefx\System\Globalization and what's in Globalization with your changes. There are cosmetic changes, some things got converted back to having m_ prefixes, ... .

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

this may be because we had the formatting changes and I had to merge with it. I'll check renamed m_*

using System.Collections.Generic;

#if INSIDE_CLR
using Kernel32 = Interop.Kernel32;
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.

You do not need these. The CoreRT copy should be switched to kernel32.dll, etc. as well. dotnet/corert#2241

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

ok I'll clean these then

{
EnumCalendarsData data = new EnumCalendarsData();
data.userOverride = 0;
#if INSIDE_CLR
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.

We should just use #if CORECLR for these. INSIDE_CLR is hard to decipher.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I didn't introduce INSIDE_CLR, it was there and I just used it. I can use CORECLR but we need to check if this not compiled for corert/PN

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.

I know you have not introduced INSIDE_CLR. We have several different ifdefs that are used for this purpose because of they were introduced by different people at different times. I am suggesting that #if CORECLR is the one we should standardize on because of it is the most logical one.

Copy link
Copy Markdown
Member

@danmoseley danmoseley Feb 28, 2017

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I checked corert and not using CORECLR as expected. so I'll change my ifdef's to CORECLR.

@jkotas
Copy link
Copy Markdown
Member

jkotas commented Feb 27, 2017

cc @alexperovich

@tarekgh
Copy link
Copy Markdown
Member Author

tarekgh commented Feb 27, 2017

@mellinoe did you see such failure in Windows_NT x86 Checked Build and Test (Jit - CoreFx) before? https://ci.dot.net/job/dotnet_coreclr/job/master/job/jitstress/job/x86_checked_windows_nt_corefx_baseline_prtest/18/

looks unrelated to my changes.

Unhandled Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

@danmoseley
Copy link
Copy Markdown
Member

/cc @krwq you won't have time to review this but as a Glob co owner you should be aware of it ..

This change is merging the globalization code used for Linux and Windows. here Is come notes about this merge:
-	Mainly picked most of the code from the corefx folder as it is well formatted and cleaned up before and then tweaked the implementation to work on Windows
-	Tries to reduce the dependencies from Globalization code on the VM. this will give flexibility to work on the code without worrying the VM
-	Provided the missing implementation as I removed many internal calls to the VM. This also help in having .Net Native have complete implementation for .net standard 2.0
-	We may need to have some small tweaks when merging this globalization code to corert
-   We'll need to do some clean up for the code which not used anymore in the VM
@tarekgh
Copy link
Copy Markdown
Member Author

tarekgh commented Feb 28, 2017

@dotnet-bot test this please

@tarekgh
Copy link
Copy Markdown
Member Author

tarekgh commented Feb 28, 2017

@mmitche do you know why the CI is not running on this PR?

@mmitche
Copy link
Copy Markdown
Member

mmitche commented Feb 28, 2017

@tarekgh GitHub is having issues with their webhooks. Please see the DDIT outage mail just sent a few minutes ago (and let me know if you didn't get it). They do appear to be coming back online and undelivered hooks are being delivered in some cases.

@mellinoe
Copy link
Copy Markdown

@tarekgh We have seen some intermittent issues in the Vector tests, presumably due to the x86 bringup.

@pgavlin were you looking into some of those?

@tarekgh
Copy link
Copy Markdown
Member Author

tarekgh commented Feb 28, 2017

@jkotas I have fixed all issues according to your comments. please let me know if you have any more comments. thanks.

{
EnumCalendarsData data = new EnumCalendarsData();
data.userOverride = 0;
#if CORECLR
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.

Other places are using using under #if CORECLR at the top of the file to reduce number of ifdefs. Do the same here?

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.

(And other places with the same pattern.)

using System.Diagnostics.Contracts;
using System.Runtime.Serialization;
using System.Threading;
#if FEATURE_APPX && !FEATURE_COREFX_GLOBALIZATION
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.

What does FEATURE_COREFX_GLOBALIZATION mean now that you have gotten rid of it? Should this ifdef be deleted?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

FEATURE_COREFX_GLOBALIZATION is mainly reflecting Linux. this is how is defined awhile ago. I agree it is not needed here. I'll remove it

using System.Diagnostics.Contracts;
using System.Runtime.Serialization;
using System.Threading;
#if FEATURE_APPX && !FEATURE_COREFX_GLOBALIZATION
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.

The WinRT specific stuff (FEATURE_APPX) should be in CultureInfo.Windows.cs

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.

Multiple places - there should be no FEATURE_APPX ifdef in this file

@@ -61,11 +61,11 @@ sealed public partial class NumberFormatInfo : ICloneable, IFormatProvider
internal String numberGroupSeparator = ",";
internal String currencyGroupSeparator = ",";
internal String currencyDecimalSeparator = ".";
#if FEATURE_COREFX_GLOBALIZATION
internal String currencySymbol = "$"; // TODO: CoreFX #846 Restore to the original value "\x00a4"; // U+00a4 is the symbol for International Monetary Fund.
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.

This looks like a hack that we forgot to cleanup. Shouldn't we rather get rid of it than keep replicating it?

byte [] keyData = null;
if (source.Length == 0)
{
keyData = EmptyArray<Byte>.Value;
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.

EmptyArray<byte>.Value is not going to compile in CoreRT. Could you please use Array.Empty<byte>() instead?

@@ -82,7 +82,7 @@ private unsafe int GetHashCodeOfStringCore(string source, CompareOptions options

fixed (char* pSource = source)
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.

Does this have the hashcode randomization like the existing CoreCLR Windows version?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

CoreCLR doesn't do randomization on the hash when requesting the linguistic hash code. look at the original

https://github.com/dotnet/coreclr/blob/master/src/mscorlib/src/System/Globalization/CompareInfo.cs#L1188

it is passing false for the randomization.
randomized hash done on the string but not on CompareInfo.

Copy link
Copy Markdown
Member

@jkotas jkotas Feb 28, 2017

Choose a reason for hiding this comment

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

The randomized string hashing should be unconditionally enabled in .NET Core. It should not matter what you pass in here, it will be overridden by s_NlsHashProvider.GetUseRandomHashing() in the QCall.

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.

You can remove the bool flag for randomized string hashing while you are on it because of it is unused.

@tarekgh
Copy link
Copy Markdown
Member Author

tarekgh commented Mar 1, 2017

Thanks @jkotas. I think I have addressed all your comments.

@pgavlin
Copy link
Copy Markdown

pgavlin commented Mar 1, 2017

@mellinoe: that failure is not something I've seen before. I'll look into it.

@tarekgh
Copy link
Copy Markdown
Member Author

tarekgh commented Mar 1, 2017

@dotnet-bot test Windows_NT x86 corefx_baseline
@dotnet-bot test Ubuntu x64 corefx_baseline
@dotnet-bot test Windows_NT x64 corefx_baseline

@tarekgh tarekgh merged commit a2c684d into dotnet:master Mar 1, 2017
jorive pushed a commit to guhuro/coreclr that referenced this pull request May 4, 2017
* Merging the Globalization code in coreclr

This change is merging the globalization code used for Linux and Windows. here Is come notes about this merge:
-	Mainly picked most of the code from the corefx folder as it is well formatted and cleaned up before and then tweaked the implementation to work on Windows
-	Tries to reduce the dependencies from Globalization code on the VM. this will give flexibility to work on the code without worrying the VM
-	Provided the missing implementation as I removed many internal calls to the VM. This also help in having .Net Native have complete implementation for .net standard 2.0
-	We may need to have some small tweaks when merging this globalization code to corert
-   We'll need to do some clean up for the code which not used anymore in the VM

* Fix ifdef's

* Fix field name in linux build

* Fix field name in linux compilation

* Misc cleanup & return randomized hashing

* Fix missing method for Linux

* one more minor fix

* Fix Linux build
@ViktorHofer
Copy link
Copy Markdown
Member

@tarekgh it seems like not all changes from this PR are synced into corert. E.g. CultureInfo._name in coreclr is CultureInfo.m_name in corert.

@tarekgh
Copy link
Copy Markdown
Member Author

tarekgh commented Jun 30, 2017

@ViktorHofer this PR was merging the globalization implementation between Linux and Windows. it was not touching corert. during that time the serialization was not a concern.

@karelz karelz modified the milestone: 2.0.0 Aug 28, 2017
@tarekgh tarekgh deleted the GlobalizationMerge branch March 25, 2019 15:30
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
* Merging the Globalization code in coreclr

This change is merging the globalization code used for Linux and Windows. here Is come notes about this merge:
-	Mainly picked most of the code from the corefx folder as it is well formatted and cleaned up before and then tweaked the implementation to work on Windows
-	Tries to reduce the dependencies from Globalization code on the VM. this will give flexibility to work on the code without worrying the VM
-	Provided the missing implementation as I removed many internal calls to the VM. This also help in having .Net Native have complete implementation for .net standard 2.0
-	We may need to have some small tweaks when merging this globalization code to corert
-   We'll need to do some clean up for the code which not used anymore in the VM

* Fix ifdef's

* Fix field name in linux build

* Fix field name in linux compilation

* Misc cleanup & return randomized hashing

* Fix missing method for Linux

* one more minor fix

* Fix Linux build


Commit migrated from dotnet/coreclr@a2c684d
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants