unascribed / FlexVer

A SemVer-compatible intuitive comparator for free-form versioning strings as seen in the wild, designed to sort versions like people do.
Creative Commons Zero v1.0 Universal
64 stars 10 forks source link

feat/csharp #16

Closed John-Paul-R closed 1 year ago

John-Paul-R commented 1 year ago

This should be a mostly 1:1 port of the java version


unascribed commented 1 year ago

I'll try to compile and test this in Mono when I get a chance.

John-Paul-R commented 1 year ago

Do you have any particular preferences around how this gets published to NuGet? Figuring out that bit as I go atm.

Current state of the publish info: https://github.com/unascribed/FlexVer/blob/2e3b64c64157b6719b65399b634c24c93933536c/csharp/FlexVer/FlexVer.nuspec

unascribed commented 1 year ago

I know absolutely nothing about NuGet, so, not really anything I can add.

unascribed commented 1 year ago

Does not build for me:

Microsoft (R) Build Engine version 16.10.1 for Mono
Copyright (C) Microsoft Corporation. All rights reserved.

Building the projects in this solution one at a time. To enable parallel build, please add the "-m" switch.
Build started 5/11/2023 10:15:12 AM.
Project "/tmp/tmp.Wdct2JtOgi/FlexVer/csharp/FlexVer.sln" on node 1 (default targets).
ValidateSolutionConfiguration:
  Building solution configuration "Debug|Any CPU".
Project "/tmp/tmp.Wdct2JtOgi/FlexVer/csharp/FlexVer.sln" (1) is building "/tmp/tmp.Wdct2JtOgi/FlexVer/csharp/FlexVer/FlexVer.csproj" (2) on node 1 (default targets).
/usr/lib/mono/msbuild/Current/bin/Microsoft.Common.CurrentVersion.targets(1232,5): error MSB3971: The reference assemblies for ".NETFramework,Version=v7.0" were not found. You might be using an older .NET SDK to target .NET 5.0 or higher. Update Visual Studio and/or your .NET SDK. [/tmp/tmp.Wdct2JtOgi/FlexVer/csharp/FlexVer/FlexVer.csproj]
_CleanRecordFileWrites:
  Creating directory "obj/Debug/net7.0/".
Done Building Project "/tmp/tmp.Wdct2JtOgi/FlexVer/csharp/FlexVer/FlexVer.csproj" (default targets) -- FAILED.
Project "/tmp/tmp.Wdct2JtOgi/FlexVer/csharp/FlexVer.sln" (1) is building "/tmp/tmp.Wdct2JtOgi/FlexVer/csharp/FlexVerTests/FlexVerTests.csproj" (3) on node 1 (default targets).
/usr/lib/mono/msbuild/Current/bin/Microsoft.Common.CurrentVersion.targets(1232,5): error MSB3971: The reference assemblies for ".NETFramework,Version=v7.0" were not found. You might be using an older .NET SDK to target .NET 5.0 or higher. Update Visual Studio and/or your .NET SDK. [/tmp/tmp.Wdct2JtOgi/FlexVer/csharp/FlexVerTests/FlexVerTests.csproj]
_CleanRecordFileWrites:
  Creating directory "obj/Debug/net7.0/".
Done Building Project "/tmp/tmp.Wdct2JtOgi/FlexVer/csharp/FlexVerTests/FlexVerTests.csproj" (default targets) -- FAILED.
Done Building Project "/tmp/tmp.Wdct2JtOgi/FlexVer/csharp/FlexVer.sln" (default targets) -- FAILED.

Build FAILED.

"/tmp/tmp.Wdct2JtOgi/FlexVer/csharp/FlexVer.sln" (default target) (1) ->
"/tmp/tmp.Wdct2JtOgi/FlexVer/csharp/FlexVer/FlexVer.csproj" (default target) (2) ->
(GetReferenceAssemblyPaths target) -> 
  /usr/lib/mono/msbuild/Current/bin/Microsoft.Common.CurrentVersion.targets(1232,5): error MSB3971: The reference assemblies for ".NETFramework,Version=v7.0" were not found. You might be using an older .NET SDK to target .NET 5.0 or higher. Update Visual Studio and/or your .NET SDK. [/tmp/tmp.Wdct2JtOgi/FlexVer/csharp/FlexVer/FlexVer.csproj]

"/tmp/tmp.Wdct2JtOgi/FlexVer/csharp/FlexVer.sln" (default target) (1) ->
"/tmp/tmp.Wdct2JtOgi/FlexVer/csharp/FlexVerTests/FlexVerTests.csproj" (default target) (3) ->
  /usr/lib/mono/msbuild/Current/bin/Microsoft.Common.CurrentVersion.targets(1232,5): error MSB3971: The reference assemblies for ".NETFramework,Version=v7.0" were not found. You might be using an older .NET SDK to target .NET 5.0 or higher. Update Visual Studio and/or your .NET SDK. [/tmp/tmp.Wdct2JtOgi/FlexVer/csharp/FlexVerTests/FlexVerTests.csproj]

    0 Warning(s)
    2 Error(s)

Time Elapsed 00:00:00.45

Does Mono not support the version of .NET you've used? I know literally nothing about the .NET ecosystem, kinda out of my depth.

unascribed commented 1 year ago
$ mcs FlexVer/FlexVerComparer.cs
FlexVer/FlexVerComparer.cs(15,17): error CS1525: Unexpected symbol `;'
FlexVer/FlexVerComparer.cs(25,6): error CS1514: Unexpected symbol `public', expecting `.' or `{'
FlexVer/FlexVerComparer.cs(34,10): error CS1644: Feature `pattern matching' cannot be used because it is not part of the C# 7.0 language specification
FlexVer/FlexVerComparer.cs(34,28): error CS1644: Feature `pattern matching' cannot be used because it is not part of the C# 7.0 language specification
FlexVer/FlexVerComparer.cs(35,10): error CS1644: Feature `pattern matching' cannot be used because it is not part of the C# 7.0 language specification
FlexVer/FlexVerComparer.cs(48,9): error CS1644: Feature `pattern matching' cannot be used because it is not part of the C# 7.0 language specification
FlexVer/FlexVerComparer.cs(49,9): error CS1644: Feature `pattern matching' cannot be used because it is not part of the C# 7.0 language specification
FlexVer/FlexVerComparer.cs(64,61): error CS1014: A get or set accessor expected
FlexVer/FlexVerComparer.cs(80,3): error CS0589: Internal compiler error during parsingSystem.InvalidCastException: Specified cast is not valid.
  at Mono.CSharp.CSharpParser.case_305 () [0x00015] in <798cc512ec0246288e0ea46d67959405>:0 
  at Mono.CSharp.CSharpParser.yyparse (Mono.CSharp.yyParser.yyInput yyLex) [0x02169] in <798cc512ec0246288e0ea46d67959405>:0 
  at Mono.CSharp.CSharpParser.parse () [0x00028] in <798cc512ec0246288e0ea46d67959405>:0 
Compilation failed: 9 error(s), 0 warnings

Guess it doesn't.

I'll just merge this if you say it works, then. I don't have any Windows systems around.

John-Paul-R commented 1 year ago

I've been using MS's dotnet distributions on linux (instead of Mono) without issue for a while now. If you want to get that running, AUR has it, and here are the MS 'dotnet on linux' docs.

I have verified that the tests pass on my machine, though, yes.

I can set up a build & test github action for this pretty easily for verification. Lmk if you think that'd fit here, and I'll push an update to this PR!

unascribed commented 1 year ago

I like for all of the implementations to have an Actions workflow that verifies the tests pass, so that would be a nice thing to add.

John-Paul-R commented 1 year ago

GH Action added!