Expose ConcurrentDictionary GetOrAdd/AddOrUpdate overloads in netcoreapp1.1#13828
Expose ConcurrentDictionary GetOrAdd/AddOrUpdate overloads in netcoreapp1.1#13828ianhays merged 3 commits intodotnet:masterfrom
Conversation
Adds one overload to each of GetOrAdd and AddOrUpdate. These overloads accept a generic argument that is passed through to any invocations of the supplied delegates, enabling developers to avoid delegate/closure allocations when more input is needed than just the key or existing value. For AddOrUpdate, there are two existing overloads with delegates; this only provide a new overload for the one that accepts two delegates.
| case 2: | ||
| if (s_getOrAddNetCoreApp11 != null) | ||
| { | ||
| s_getOrAddNetCoreApp11(dict, j); |
There was a problem hiding this comment.
This is kinda ugly... I wanted to move the tests for the new APIs out to separate test file (which seems to be the preferred way), but also wanted to keep this particular test intact. This is what I came up with to accomplish that. However, in this case, ifdefs in the tests might be cleaner, and there is some precedent with #13199, for example. @stephentoub, do you have a preference?
There was a problem hiding this comment.
An alternative would be to implement the new method behavior as extension methods in the test that are compiled in only when testing the older version, and then leave this test itself clean.
| @@ -5,6 +5,7 @@ | |||
| <AssemblyVersion>4.0.10.0</AssemblyVersion> | |||
There was a problem hiding this comment.
Should the version not go up if public members are added?
There was a problem hiding this comment.
I bumped the version (though, I'm not confident I changed it in all the right places). Tests pass locally, but CI is now failing across the board (previously was green) and I'm not sure what the issue is. Hmm.
There was a problem hiding this comment.
I was as much asking because I'm not confident I bumped the right places on something I'm working on :(
There was a problem hiding this comment.
Yep, I just followed your lead from your PR.
There was a problem hiding this comment.
Well since the last change I tried there was copying something here, that's like Pooh and Piglet hunting Woozles and following their own footprints around a tree.
d6c0a76 to
64e42cc
Compare
|
Since this is adding new APIs, the minor version should be incremented. What files need to be updated to bump the version to 4.1.0.0? I tried updating the following:
Tests passed for me locally, but CI was failing across the board and I couldn't find a reason for the failures. So I've reverted the version changes for now (CI is back to green). |
|
Thanks, Justin. The src/test changes LGTM. @weshaggard or @joperezr could probably help with the ref/version stuff. |
| @@ -5,6 +5,7 @@ | |||
| <AssemblyVersion>4.0.10.0</AssemblyVersion> | |||
There was a problem hiding this comment.
You do have to upgrade the version at least for the netcoreapp1.1 framework since you are adding API there. To do so, please update src/System.Collections.Concurrent/dir.props to have it's assembly version be 4.1.0.0. Also, you will need to keep this declaration in here, but you will need to add a Condition like:
<AssemblyVersion Condition="'$(TargetGroup)'=='netstandard1.3'">4.0.10.0</AssemblyVersion>| <ItemGroup> | ||
| <Project Include="System.Collections.Concurrent.csproj" /> | ||
| <Project Include="System.Collections.Concurrent.csproj"> | ||
| <TargetGroup>netcoreapp1.1</TargetGroup> |
There was a problem hiding this comment.
Could you please make netcoreapp1.1 the default? that wold mean changing the .csproj to have netcoreapp1.1 as the nuget target moniker by default, and in here you will be cross compiling for netstandard1.3 instead. The reason to do this is because you want the default build of the .csproj to be the newest version of it.
| <TestTFMs>netcoreapp1.0</TestTFMs> | ||
| </Project> | ||
| <Project Include="System.Collections.Concurrent.Tests.csproj"> | ||
| <TargetGroup>netcoreapp1.1</TargetGroup> |
There was a problem hiding this comment.
<TestTFMs>netcoreapp1.1</TestTFMs>
This is already the default so you don't need it.
|
Looks like you are not crosscompiling the src for netcoreapp1.1 which is something that you have to fix. To do this, add a new configuration in your src/System.Collections.Concurrent.builds file for netcoreapp1.1, and then make sure that you are defining the |
|
@justinvp have you had a chance to address feedback? |
|
oops |
|
@danmosemsft, sorry, I haven't had time to work through getting the version incremented. Will try to get to it in the next week or so. |
|
@joperezr, I made changes based on your feedback, but something still isn't right and I'm not familiar enough with the build/packaging to know what needs to be changed to address it. Here's one of the errors at the end of msbuild.log from one of the CI builds:
Any ideas? |
| <ItemGroup> | ||
| <ProjectReference Include="..\ref\System.Collections.Concurrent.csproj"> | ||
| <ProjectReference Include="..\ref\System.Collections.Concurrent.builds"> | ||
| <SupportedFramework>net46;netcore50;netcoreapp1.0;$(AllXamarinFrameworks)</SupportedFramework> |
There was a problem hiding this comment.
This should be updated to <SupportedFramework>netcoreapp1.1;net463;$(AllXamarinFrameworks)</SupportedFramework>
| <ItemGroup> | ||
| <Project Include="System.Collections.Concurrent.csproj" /> | ||
| <Project Include="System.Collections.Concurrent.csproj"> | ||
| <TargetGroup>netstandard1.3</TargetGroup> |
There was a problem hiding this comment.
Not 100% sure but you many need to remove this netstandard1.3 build configuration as well. It will automatically be harvested from the last stable package.
| <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'" /> | ||
| <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'net46_Debug|AnyCPU'" /> | ||
| <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'net46_Release|AnyCPU'" /> | ||
| <ItemGroup Condition="'$(TargetGroup)' == 'netstandard1.3'"> |
There was a problem hiding this comment.
This isn't necessary as this project doesn't build a netstandard1.3 build configuration.
|
Thanks, Wes. I made changes per your suggestions, but now seeing new errors in msbuild.log: Any ideas? |
| }, | ||
| "frameworks": { | ||
| "netstandard1.3": {} | ||
| "netstandard1.3": {}, |
There was a problem hiding this comment.
should this be netstandard1.7?
There was a problem hiding this comment.
no, there is no new API for netstandard so this is fine.
| <OutputType>Library</OutputType> | ||
| <NuGetTargetMoniker>.NETStandard,Version=v1.3</NuGetTargetMoniker> | ||
| <NuGetTargetMoniker Condition="'$(TargetGroup)'==''">.NETCoreApp,Version=v1.1</NuGetTargetMoniker> | ||
| <DefineConstants Condition="'$(TargetGroup)'==''">$(DefineConstants);netcoreapp11</DefineConstants> |
There was a problem hiding this comment.
Are these ever false? The only entry in the builds file has a null TargetGroup.
There was a problem hiding this comment.
yes, if we x-compile for netstandard1.3
|
|
||
| namespace System.Collections.Concurrent.Tests | ||
| { | ||
| // Allows the ConcurrentDictionary tests to run on targets that do not have the new GetOrAdd/AddOrUpdate overloads. |
There was a problem hiding this comment.
Why? What's the purpose in testing a function that doesn't actually exist in that version?
There was a problem hiding this comment.
It wasn't as clean to separate out the tests into a separate file in this case. Steve suggested the extension methods. #13828 (comment)
| <TargetGroup>netstandard1.3</TargetGroup> | ||
| <TestTFMs>netcoreapp1.0</TestTFMs> | ||
| </Project> | ||
| <Project Include="System.Collections.Concurrent.Tests.csproj"> |
There was a problem hiding this comment.
You may need to set TestTFMs.
There was a problem hiding this comment.
I had that originally, but removed based on feedback from Jose as it's the default. #13828 (comment)
| <Import Project="..\dir.props" /> | ||
| <PropertyGroup> | ||
| <AssemblyVersion>4.0.14.0</AssemblyVersion> | ||
| <AssemblyVersion>4.1.0.0</AssemblyVersion> |
There was a problem hiding this comment.
I talked with @ericstj and it looks like we intentionally keep AssemblyVersion as it was when we are adding API for core-only. So in this case, I guess that we have to revert this change, and that might solve your build issue.
There was a problem hiding this comment.
Yes, I believe so. cc: @ericstj @stephentoub Should we log an issue to track reverting that change and bring the assembly version down again given that api changes were only for netcoreapp1.1?
| <ProjectReference Include="..\ref\System.Collections.Concurrent.csproj"> | ||
| <SupportedFramework>net46;netcore50;netcoreapp1.0;$(AllXamarinFrameworks)</SupportedFramework> | ||
| <ProjectReference Include="..\ref\System.Collections.Concurrent.builds"> | ||
| <SupportedFramework>netcoreapp1.1;net463;$(AllXamarinFrameworks)</SupportedFramework> |
There was a problem hiding this comment.
net463 [](start = 40, length = 6)
Let's remove net463 from here since we are not exposing any new API for it.
There was a problem hiding this comment.
I think this should also fix your current build issue.
| <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> | ||
| <PropertyGroup> | ||
| <AssemblyVersion>4.0.10.0</AssemblyVersion> | ||
| <AssemblyVersion Condition="'$(TargetGroup)'=='netstandard1.3'">4.0.10.0</AssemblyVersion> |
There was a problem hiding this comment.
As I said on my previous comment on the dir.props file, I misguided you to update this AssemblyVersion, since it looks like we only want to update the AssemblyVersion whenever we expose new API for netstandard and not when we only expose it for netcoreapp. That means that this should go back to being: <AssemblyVersion>4.0.10.0</AssemblyVersion> That should fix your build issue.
9d4fda1 to
a5c20bc
Compare
|
I reverted the version bump per @joperezr's feedback (#13828 (comment)). CI all green now. |
joperezr
left a comment
There was a problem hiding this comment.
LGTM. thanks for fixing the version
|
Unless there's any other feedback, this should be good to merge. |
…nary Expose ConcurrentDictionary GetOrAdd/AddOrUpdate overloads in netcoreapp1.1 Commit migrated from dotnet/corefx@7d64cf1
Port #1783 from future to master. Contributes to #2869.
I cherry-picked (and slightly tweaked) the two relevant commits from the future branch:
throw null;style)I then added a third commit that cleaned some things up, extracted tests, and exposed the APIs in netcoreapp1.1.
cc: @stephentoub