-
Notifications
You must be signed in to change notification settings - Fork 353
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
Target .NET Standard 2.0 #103
Conversation
- simplify .NET Standard projects and use Microsoft.NET.Sdk in test project - depend on Newtonsoft.Json v10 and Newtonsoft.Json.Bson v1 packages - Newtonsoft.Json v9.0.1 has a reduced API when targeting .NET Standard - adjust a few tests to handle changes between v9 and v10 - test .NET Standard library on both .NET 4.6.1 and .NET Core 2.0 - update test/Directory.Build.targets to handle testing with .NET Core; use it from Runtime.msbuild - adjust a few tests to handle .NET Core 2.0 differences and gaps - found and fixed a broken test in `HttpValueCollectionTest`
<NoWarn>1591</NoWarn> | ||
<TargetFrameworkVersion></TargetFrameworkVersion> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This oddity goes away with new condition in Directory.Build.props.
<Compile Include="..\System.Net.Http.Formatting.NetCore\MediaTypeHeaderValueExtensions.cs"> | ||
<Link>MediaTypeHeaderValueExtensions.cs</Link> | ||
|
||
<Compile Include="..\System.Net.Http.Formatting\**\*.cs"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I confirmed desktop project includes every source file in its folder.
<CodeAnalysisAdditionalOptions> /assemblycomparemode:StrongNameIgnoringVersion</CodeAnalysisAdditionalOptions> | ||
<CodeAnalysisSearchGlobalAssemblyCache>false</CodeAnalysisSearchGlobalAssemblyCache> | ||
<DefineConstants>$(DefineConstants);NETFX_CORE;ASPNETMVC;NOT_CLS_COMPLIANT;NETSTANDARD1_1</DefineConstants> | ||
<RunCodeAnalysis>false</RunCodeAnalysis> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FxCop of this project is now completely redundant. In addition, even the newest command-line FxCop tool has trouble with .NET Standard libraries and the even-newer Roslyn analyzers can't load this particular library.
if (Type.GetType(_netCore20TypeName, throwOnError: false) != null) | ||
{ | ||
// Treat .NET Core 2.0 as a .NET 4.5 superset though internal types are different. | ||
return Platform.Net45; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for a runtime check whether test is running on .NET Core. Only the test assembly built for .NET Core is run on .NET Core.
<RootNamespace>System.Net.Http</RootNamespace> | ||
<AssemblyName>System.Net.Http.Formatting.NetStandard.Test</AssemblyName> | ||
<OutputPath>..\..\bin\$(Configuration)\Test\NetStandard\</OutputPath> | ||
<DefineConstants>$(DefineConstants);NETFX_CORE</DefineConstants> | ||
<OutputPath>..\..\bin\$(Configuration)\Test\</OutputPath> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test assemblies land in ..\..\bin\$(Configuration)\Test\net461
and ..\..\bin\$(Configuration)\Test\netcoreapp2.0
.
@@ -458,6 +462,7 @@ IEnumerator<T> IEnumerable<T>.GetEnumerator() | |||
[Serializable] | |||
class SerializableType : IEquatable<SerializableType> | |||
{ | |||
[JsonConstructor] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Required when testing on .NET Core 2.0. But, does no harm anywhere…
@@ -202,29 +205,24 @@ private static void Create_CreateDoesntThrowTooManyValuesPrivate() | |||
[Fact] | |||
public void AddTooManyKeysThrows() | |||
{ | |||
RunInIsolation(Create_CreateDoesntThrowTooManyValuesPrivate); | |||
RunInIsolation(AddTooManyKeysThrowsPrivate); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test was previously a duplicate.
// Act && Assert | ||
Assert.Throws<InvalidOperationException>( | ||
() => collection.Add(_maxCollectionKeys.ToString(), _maxCollectionKeys.ToString()), | ||
TooManyKeysError); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Turns out the static
keyword was all I need to get test working everywhere. But, updated test does the same thing and is easier to read.
This is most of the fix for #101. Remainder in CodeFlow… |
HttpValueCollectionTest