Skip to content
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

Modernize project and target .NET Standard 2.0 #12

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

0xced
Copy link

@0xced 0xced commented Apr 21, 2021

  • Upgrade projects to the new "SDK style" csproj format

    • Remove the packages directory and packages.config file
    • Remove AssemblyInfo.cs files (replaced with equivalent csproj properties)
    • Remove *.vsmdi and *.testsettings files
    • Run tests on .NET Framework 4.7.2 + .NET Core 3.1 + .NET 6.0
    • Update test dependencies to their latest version
      • Microsoft.NET.Test.Sdk → 17.1.0
      • Moq → 4.16.1
      • MSTest.TestAdapter → 2.2.8
      • MSTest.TestFramework → 2.2.8
  • Use System.Text.Json instead of System.Web.Script.Serialization

    • Use JsonPropertyNameAttribute instead of FieldAttribute
    • Make properties { get; init; } instead of { get; internal set; } with the help of the IsExternalInit NuGet package to support .NET Standard 2.0
    • Define JsonPropertyName attributes for all enums and use JsonStringEnumMemberConverter from the Macross.Json.Extensions NuGet package to workaround issues in JsonStringEnumConverter

Fixes #11

/cc @jskeet @petrsvihlik

There were two issues in the validation.
1. Parsing the version as a double with the _current_ culture: the decimal separator is not necessarily a dot but might be a comma for example.
2. Using a double to compare a version number. Comparing with the double type, 2.11 is smaller than 2.2 which is not what we want when comparing version numbers.

Using System.Version to compare the version numbers fixes both issues.
StacMan/QuestionTimelines/TimelineType.cs Outdated Show resolved Hide resolved

public static readonly IDictionary<string, PropertyInfo> Value;
}

public static class SortsBySortType<TSort> where TSort : struct // proxy for "where TSort: enum"
{
static SortsBySortType()
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not used. How did you preserve the original logic?

var sortsBySortType = ReflectionCache.SortsBySortType<TSort>.Value;

& The same question for ApiFieldsByName.

Copy link
Author

Choose a reason for hiding this comment

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

This is not used.

I don't understand what you mean, I think it's definitely used. Maybe you got fooled by all the parameters being grayed out by ReSharper? (They are greyed out because the are only used for precondition checks, which is the purpose of this ValidateSortMinMax method.)

The same question for ApiFieldsByName.

I haven't really looked into this. I saw some manual code to map the JSON with System.Web.Script.Serialization (which I have never used) and figured that replacing all this manual mapping with System.Text.Json would be semantically equivalent. All the tests passing comforted me into this idea.

Copy link
Contributor

Choose a reason for hiding this comment

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

ad SortsBySortType - please disregard my remark. I must have overlooked that
ApiFieldsByName - yeah, that seems to be the case :)

let's see what @emmettnicholas has to say regarding this PR

@petrsvihlik
Copy link
Contributor

@0xced It looks good overall! :) I have just two little remarks.

* Upgrade projects to the new "SDK style" csproj format
  * Remove the packages directory and packages.config file
  * Remove `AssemblyInfo.cs` files (replaced with equivalent csproj properties)
  * Remove `*.vsmdi` and `*.testsettings` files
  * Run tests on .NET Framework 4.7.2 + .NET Core 3.1 + .NET 6.0
  * Update test dependencies to their latest version 
    * Microsoft.NET.Test.Sdk → 17.1.0
    * Moq → 4.16.1
    * MSTest.TestAdapter → 2.2.8
    * MSTest.TestFramework → 2.2.8

* Use `System.Text.Json` instead of `System.Web.Script.Serialization`
  * Use `JsonPropertyNameAttribute` instead of `FieldAttribute`
  * Make properties `{ get; init; }` instead of `{ get; internal set; }` with the help of the `IsExternalInit` NuGet package to support .NET Standard 2.0
  * Define `JsonPropertyName` attributes for all enums and use `JsonStringEnumMemberConverter` from the `Macross.Json.Extensions` NuGet package to workaround [issues in JsonStringEnumConverter](dotnet/runtime#31619)

Fixes emmettnicholas#11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Any chance of a build supporting netstandard2.0?
2 participants