Add new Queue and Stack APIs#12047
Conversation
|
@hughbe Thank you 👍 |
|
I'm getting test failures of |
nevermind, i see now that you already have that. I'll try to repro locally. |
|
@ianhays It seems that this is already added to the project.. https://github.com/hughbe/corefx/blob/c815b7677764864a57a4cae3939fd6cf56ac5e04/src/System.Collections/tests/project.json#L28 |
|
The implementations of the new members LGTM. |
|
Thanks. @ianhays i ran the tests locally (msbuild /T:BuildAndTest /P:TargetGroup=netstandard1.7) and I got these errors), so I can reproduce the CI errors when specifying the target group. |
Sorry about your trouble with the API addition Hugh. It's a pretty complicated process right now with the update to netstandard1.7, particularly since some libraries have been updated while others are still building netstandard1.3. It's still very much in flux, so I don't think we have any docs for it (at least I'm not aware of any). System.Collections is one that has already been updated to netstandard1.7, so you shouldn't need to do any of the structural changes around versioning from this PR.
Unfortunately #11689 is a special case where Jeremy wanted some components to be exposed only for .NET Core (netcoreapp1.1) and not UAP (uap10.1) or net463. For most cases when adding API, we want to add those for all platforms that are adhere to netstandard1.7 (the previously mentioned), not just a particular one. For System.Collections specifically, there aren't any components that are runtime specific so the src build should be built for netstandard1.7. If you have any more in-depth questions then @joperezr can probably explain the TargetGroup/TestTFM structure better than I can since he's the one who explained it to me yesterday.
I pulled your changes, removed the netcoreapp1.1 structural stuff, and pushed a working copy to my repo that you can use as an example of what to do when a project has already been updated to build for netstandard1.7. I'd recommend you build the test builds file ( |
| } | ||
| }, | ||
| "netcoreapp1.1": {}, | ||
| "netcoreapp1.0": {} |
There was a problem hiding this comment.
Why did you need to add netcoreapp1.0?
There was a problem hiding this comment.
You can remove the netcoreapp1.0 framework as you aren't building this project for that target framework.
Once you add the build configuration I suggested you should be able to test the build and run the tests for netcoreapp1.1. I suspect you will need to add:
"System.Runtime.Serialization.Formatters": "4.3.0-beta-24522-03"
Under your netcoreapp1.1 section here as well, in order to get that dependency passed for the netcoreapp1.1 build.
| Assert.Equal(itemToAdd, q.Dequeue()); | ||
| } | ||
|
|
||
| #if netcoreapp11 |
There was a problem hiding this comment.
My preference would be to have these netcoreapp11 specific tests in their own file instead of using #ifdefs.
|
cc @ericstj |
| @@ -10,6 +10,7 @@ | |||
| <RootNamespace>System.Collections.Tests</RootNamespace> | |||
| <DefineConstants Condition="'$(TargetGroup)'=='netstandard1.7'">$(DefineConstants);netstandard17</DefineConstants> | |||
There was a problem hiding this comment.
You are going to need to add a build configuration in the System.Collections.Tests.builds file in order to get this netcoreapp1.1 build setup.
There was a problem hiding this comment.
Something along the lines of:
<Project Include="System.Collections.Tests.csproj">
<TargetGroup>netcoreapp1.1</TargetGroup>
<TestTFMs>netcoreapp1.1</TestTFMs>
</Project>
Then to build and run the tests you either needs to msbuild System.Collections.Tests.csproj /p:TargetGroup=netcoreapp1.1
|
@ianhays Thanks! @weshaggard could you clarify if we can just expose these in netstandard1.7? thanks! |
That is correct these should be netcoreapp1.1, specific APIs. |
|
Okay! It all works guys, thanks for your help! |
|
Now the CentOs build must work too: |
| <RootNamespace>System.Collections.Tests</RootNamespace> | ||
| <DefineConstants Condition="'$(TargetGroup)'=='netstandard1.7'">$(DefineConstants);netstandard17</DefineConstants> | ||
| <NugetTargetMoniker Condition="'$(NugetTargetMoniker)'==''">.NETStandard,Version=v1.3</NugetTargetMoniker> | ||
| <DefineConstants Condition="'$(TargetGroup)' == 'netcoreapp1.1'">$(DefineConstants);netcoreapp11</DefineConstants> |
There was a problem hiding this comment.
This define is no longer needed.
weshaggard
left a comment
There was a problem hiding this comment.
one last little clean-up otherwise this change LGTM. Thanks for the contribution and working through the work of adding new APIs.
|
Thanks for the contribution @hughbe. |
Does not exist in older .NET Standard versions See: dotnet/runtime#15619 => dotnet/corefx#12047
Does not exist in older .NET Standard versions See: dotnet/runtime#15619 => dotnet/corefx#12047
Implement TryPeek and TryPop on Stack Implement TryPeek and TryDequeue on Queue Commit migrated from dotnet/corefx@de966f9
Fixes #4316
Also, adding APIs to .NET core was something of a soul destroying experience for me - very confusing as there are so many things to change and define and add. #11689 was helpful once I discovered it, but I ended up changing things without really understanding what the impact was.
/cc @benadams @page-not-found @weshaggard @stephentoub @ianhays