-
Notifications
You must be signed in to change notification settings - Fork 5.4k
[OSX] HybridGlobalization implement compare native function #85965
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
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
5406aef
Implemented CompareStringNative
mkhamoyan 3494765
moved compare function to collation file
mkhamoyan a2bd6b1
throw exception when options not supported
mkhamoyan f84b02a
Ordinal cases tests shouldn't be skipped
mkhamoyan 28f7699
Did changes requested by review
mkhamoyan ea9094b
Minor fixes in tests
mkhamoyan 461f926
Remove whitespaces
mkhamoyan 3b7a33a
Added changes done by @ilonatommy in #86305
mkhamoyan 4e4fb08
Added in docs info about compare function
mkhamoyan cf1e1c7
Minor change in doc
mkhamoyan ff743ec
Mapped StringSort to None
mkhamoyan 4c78a3b
fix spacing
mkhamoyan d558895
Minor fixes in doc
mkhamoyan f31fb4c
Merge branch 'main' into hybrid_compare_options
mkhamoyan b683bce
Updated IgnoreCase, IgnoreWith, IgnoreNonSpace
mkhamoyan 73fa470
Refactored mapping function
mkhamoyan 4ce304a
Minor changes in docs and test cases
mkhamoyan e53aa0c
Added StringSort compare option
mkhamoyan c316a26
Refactoring requested by review
mkhamoyan 199c27e
Parameter type changed from char* to unichar*
mkhamoyan b0cbfac
use const uint16_t * in both .h and .m
mkhamoyan b34d0a2
Merge branch 'main' into hybrid_compare_options
mkhamoyan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using System; | ||
| using System.Globalization; | ||
| using System.Runtime.CompilerServices; | ||
| using System.Runtime.InteropServices; | ||
|
|
||
| internal static partial class Interop | ||
| { | ||
| internal static partial class Globalization | ||
| { | ||
| [LibraryImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_CompareStringNative", StringMarshalling = StringMarshalling.Utf8)] | ||
| internal static unsafe partial int CompareStringNative(string localeName, char* lpStr1, int cwStr1Len, char* lpStr2, int cwStr2Len, CompareOptions options); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
237 changes: 148 additions & 89 deletions
237
src/libraries/System.Globalization/tests/CompareInfo/CompareInfoTests.Compare.cs
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.OSX.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using System.Buffers; | ||
| using System.Collections.Generic; | ||
| using System.Diagnostics; | ||
| using System.Runtime.InteropServices; | ||
| using System.Text; | ||
|
|
||
| namespace System.Globalization | ||
| { | ||
| public partial class CompareInfo | ||
| { | ||
| private unsafe int CompareStringNative(ReadOnlySpan<char> string1, ReadOnlySpan<char> string2, CompareOptions options) | ||
| { | ||
| Debug.Assert(!GlobalizationMode.Invariant); | ||
| Debug.Assert(!GlobalizationMode.UseNls); | ||
| Debug.Assert((options & (CompareOptions.Ordinal | CompareOptions.OrdinalIgnoreCase)) == 0); | ||
| string cultureName = m_name; | ||
|
mdh1418 marked this conversation as resolved.
Outdated
|
||
|
|
||
| // GetReference may return nullptr if the input span is defaulted. The native layer handles | ||
| // this appropriately; no workaround is needed on the managed side. | ||
|
|
||
| fixed (char* pString1 = &MemoryMarshal.GetReference(string1)) | ||
| fixed (char* pString2 = &MemoryMarshal.GetReference(string2)) | ||
| { | ||
| System.Diagnostics.Debug.Write("Collation CompareStringNative is called for culture: " + cultureName + "string1: " + string1.ToString() + "string2: " + string2.ToString() + "\n"); | ||
| var result = Interop.Globalization.CompareStringNative(cultureName, pString1, string1.Length, pString2, string2.Length, options); | ||
|
mdh1418 marked this conversation as resolved.
Outdated
|
||
| System.Diagnostics.Debug.Write("Collation CompareStringNative result: " + result + "\n"); | ||
|
mdh1418 marked this conversation as resolved.
Outdated
|
||
| return result; | ||
| } | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.