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

Expose new .netcoreapp1.1 APIs in System.Runtime #12226

Merged
merged 5 commits into from
Oct 3, 2016
Merged

Expose new .netcoreapp1.1 APIs in System.Runtime #12226

merged 5 commits into from
Oct 3, 2016

Conversation

hughbe
Copy link

@hughbe hughbe commented Sep 30, 2016

And add some tests

Fixes #10127
Fixes #8592
Fixes #2352
Fixes #692
Fixes #11090

/cc @justinvp @jamesqo @jkotas @yufeih @bartdesmet @weshaggard @danmosemsft

@hughbe
Copy link
Author

hughbe commented Sep 30, 2016

@yufeih I think there might be a bug in your implementation of the non-generic enum.TryParse. An exception is thrown if enumType is null or is not an enum. I personally wouldn't expect TryParse to ever throw an exception, and to just return false in these cases.

@yufeih
Copy link

yufeih commented Sep 30, 2016

I followed the behavior of TryParse

The following code throws ArgumentException:

int a;
Enum.TryParse<int>("--", out a);

@hughbe
Copy link
Author

hughbe commented Sep 30, 2016

Ah okay, that's fine then. Was just checking!

@hughbe
Copy link
Author

hughbe commented Sep 30, 2016

@dotnet-bot test this please (CI down)

yield return new object[] { "99", false, (SimpleEnum)99 };
yield return new object[] { "-42", false, (SimpleEnum)(-42) };
yield return new object[] { " -42", false, (SimpleEnum)(-42) };
yield return new object[] { " -42 ", false, (SimpleEnum)(-42) };
Copy link
Member

Choose a reason for hiding this comment

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

Is there a reason to prefer this approach over the InlineData approach? I don't have a strong preference I'm just trying to understand the motivation

Copy link
Member

Choose a reason for hiding this comment

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

Nevermind I see now you did this so you can share the test cases.

@@ -28,6 +28,7 @@
<Compile Include="Helpers.cs" />
<Compile Include="System\ActivatorTests.cs" />
<Compile Include="System\ArrayTests.cs" />
<Compile Include="System\ArrayTests.netcoreapp1.1.cs" Condition="'$(TargetGroup)' == 'netcoreapp1.1'" />
Copy link
Member

Choose a reason for hiding this comment

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

I would prefer these all being grouped in one ItemGroup with that ItemGroup having the condition.

Copy link
Author

Choose a reason for hiding this comment

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

done, thanks

@weshaggard
Copy link
Member

Looks like some of the System.Runtime tests are hitting some kind of interesting infinite loop or something in Release builds for your new set of tests. Please try to take a look at a Release test run for your new configuration.

@hughbe
Copy link
Author

hughbe commented Oct 1, 2016

Thanks Wes, turns out it was a bad test - the release CLR inlined a method, meaning that it never reached stack limit. Fixed by adding a NoInlining attribute

},
"netcoreapp1.1": {
"dependencies": {
"System.Runtime.Serialization.Formatters": "4.3.0-beta-24530-03"
Copy link
Member

Choose a reason for hiding this comment

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

What test actually has a dependency on this library?

Copy link
Author

Choose a reason for hiding this comment

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

I'm afk right now so can't remove the dependency and see what fails, but it was introduced in f6f97c2#diff-29df68f37e76e464ad7ef9130076abae

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for the pointer looks like @alexperovich added it to do some BinaryFormatter testing. I'm OK with this for testing purposes.

Copy link
Member

@weshaggard weshaggard left a comment

Choose a reason for hiding this comment

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

LGTM - Thanks for exposing these.

}

[Fact]
public static void TryEnsureSufficientExecutionStack_NoSpaceAvaiable_ReturnsFalse()
Copy link
Contributor

Choose a reason for hiding this comment

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

Small typo in Available.

if (!RuntimeHelpers.TryEnsureSufficientExecutionStack())
{
Assert.Throws<InsufficientExecutionStackException>(() => RuntimeHelpers.EnsureSufficientExecutionStack());
return;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this case ever hit? I.e. do we construct a deep stack in some test to assert this behavior?

Copy link
Author

Choose a reason for hiding this comment

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

Yes. If I remove this check, a StackOverflow exception is thrown - the lines below your comment recurse the method

Copy link
Member

@weshaggard weshaggard left a comment

Choose a reason for hiding this comment

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

LGTM Thanks @hughbe for your contribution.

@weshaggard weshaggard merged commit 7bc1e6d into dotnet:master Oct 3, 2016
@hughbe hughbe deleted the runtime-expose-11 branch October 3, 2016 16:31
@karelz karelz modified the milestone: 1.2.0 Dec 3, 2016
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
* Expose new .netcoreapp1.1 APIs in System.Runtime

And add some tests

Sometimes, CLR optimizations make this test invalid. Make sure we don't recurse into oblivion.


Commit migrated from dotnet/corefx@7bc1e6d
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.

6 participants