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

StringComparer.FromComparison test#19153

Merged
stephentoub merged 3 commits into
dotnet:masterfrom
MikevanDongen:StringComparerTests-FromComparisonTest
May 1, 2017
Merged

StringComparer.FromComparison test#19153
stephentoub merged 3 commits into
dotnet:masterfrom
MikevanDongen:StringComparerTests-FromComparisonTest

Conversation

@MikevanDongen
Copy link
Copy Markdown
Member

Added @AlexRadch's tests for method StringComparer.FromComparison.
See issue #13800 and PR (abandoned) #14623

public static System.StringComparer OrdinalIgnoreCase { get { throw null; } }
#if netcoreapp
public static System.StringComparer FromComparison(System.StringComparison comparisonType) { throw null; }
#endif
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 don't think we add ifdefs anymore - AFAIK we build the ref only for netcoreapp, so just remove the ifdefs and it should be fine.
Here's example: #16996

Note: I may be wrong (I didn't try it myself so far :() check the configuration of the package modified in #16996, maybe there is more to it ... cc @danmosemsft @weshaggard who know more about it

Once we clarify the steps, how-to here, please update our new contrib docs on wiki Expose API in CoreFX

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.

Correct, we don't need an #if here as we want to expose it for all platforms.

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.

Makes sense, though it was requested in #14623 (comment).
Does the second part of the referenced comment still apply?

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 did the right thing by naming the file..netcoreapp.. and conditionally compiling the file. We don't use versions anymore.

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.

Fixed this.

@karelz
Copy link
Copy Markdown
Member

karelz commented Apr 29, 2017

Given that this just exposes API which is already implemented for a while, I would consider it also for 2.0 (once it is reviewed & passes tests) - @Petermarcu thoughts?

In general we don't take new APIs and large non-critical contributions throughout May 10 - because we are stabilizing for .NET Core 2.0 release -- see details in https://github.com/dotnet/corefx/issues/17619#issuecomment-296872132. This may be an exception ... let's see what @Petermarcu says.

@karelz
Copy link
Copy Markdown
Member

karelz commented Apr 29, 2017

And of course I forgot the most important thing: Thanks for your contribution @MikevanDongen!

[MemberData(nameof(FromComparison_TestData))]
public static void FromComparisonTest(StringComparison comparison, StringComparer comparer)
{
Assert.Equal(comparer, StringComparer.FromComparison(comparison));
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.

Assert.Same?

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've just tested this, which resulted in a Xunit.Sdk.SameException when using it with CurrentCulture or CurrentCultureIgnoreCase. It seems the property always returns a new instance: https://github.com/dotnet/coreclr/blob/1a32d7f2c1be31741c3e71fe35eb2fd22664d12c/src/mscorlib/shared/System/StringComparer.cs#L38
I'm not certain why it was implemented that way, but I don't think it should be tested here using Assert.Same.

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.

Fair enough

Copy link
Copy Markdown
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.

LGTM

@stephentoub
Copy link
Copy Markdown
Member

I would consider it

We should take it.

@karelz, are there other new APIs that have been implemented in coreclr but not yet exposed in corefx? We should make sure they're all exposed.

@karelz
Copy link
Copy Markdown
Member

karelz commented Apr 30, 2017

@stephentoub yeah, there was a bunch of left-overs from @AlexRadch - I marked them originally as 2.0, but later triage decided to push them out. I tried to mark them at least as wishlist, but I don't have confidence I did it for all.
Is there a simple way to list all new 2.0 APIs exposed from CoreCLR? We could cross-check them with CoreFX-exposed list ...

@danmoseley
Copy link
Copy Markdown
Member

@karelz yes just diff corelib with the rest. Il do it.

@danmoseley
Copy link
Copy Markdown
Member

@karelz @stephentoub I looked at all the public API on corelib that isn't already exposed and marked issues to expoes each with the label "api-to-expose-from-coreclr"
Note that the issue associated with this PR has 2 api and only one is exposed by this PR.

There are also a few members on corelib that are only public for infrastructural reasons and in on case I opened a cleanup issue.

@stephentoub
Copy link
Copy Markdown
Member

Thanks for doing that, Dan.

@stephentoub stephentoub merged commit bee0a52 into dotnet:master May 1, 2017
<ProjectGuid>{6C314C9B-3D28-4B05-9B4C-B57A00A9B3B9}</ProjectGuid>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DefineConstants Condition="'$(TargetsUnix)' == 'true'" >$(DefineConstants);Unix</DefineConstants>
<DefineConstants Condition="'$(TargetGroup)'=='netcoreapp'">$(DefineConstants);netcoreapp</DefineConstants>
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.

Did you actually need this define? I didn't see it used anywhere.

@karelz karelz modified the milestone: 2.0.0 May 5, 2017
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.

9 participants