commit a5a3d87ba9a9b4720ad6f0d0bf0b4e73decfd38f Author: Smaug123 <3138005+Smaug123@users.noreply.github.com> Date: Thu Feb 13 23:30:15 2025 +0000 Initial commit diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json new file mode 100644 index 0000000..fda17c5 --- /dev/null +++ b/.config/dotnet-tools.json @@ -0,0 +1,18 @@ +{ + "version": 1, + "isRoot": true, + "tools": { + "fantomas": { + "version": "7.0.0", + "commands": [ + "fantomas" + ] + }, + "fsharp-analyzers": { + "version": "0.28.0", + "commands": [ + "fsharp-analyzers" + ] + } + } +} \ No newline at end of file diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..e207c42 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,40 @@ +root=true + +[*] +charset=utf-8 +trim_trailing_whitespace=true +insert_final_newline=true +indent_style=space +indent_size=4 + +# ReSharper properties +resharper_xml_indent_size=2 +resharper_xml_max_line_length=100 +resharper_xml_tab_width=2 + +[*.{csproj,fsproj,sqlproj,targets,props,ts,tsx,css,json}] +indent_style=space +indent_size=2 + +[*.{fs,fsi}] +fsharp_bar_before_discriminated_union_declaration=true +fsharp_space_before_uppercase_invocation=true +fsharp_space_before_class_constructor=true +fsharp_space_before_member=true +fsharp_space_before_colon=true +fsharp_space_before_semicolon=true +fsharp_multiline_bracket_style=aligned +fsharp_newline_between_type_definition_and_members=true +fsharp_align_function_signature_to_indentation=true +fsharp_alternative_long_member_definitions=true +fsharp_multi_line_lambda_closing_newline=true +fsharp_experimental_keep_indent_in_branch=true +fsharp_max_value_binding_width=80 +fsharp_max_record_width=0 +max_line_length=120 +end_of_line=lf + +[*.{appxmanifest,build,dtd,nuspec,xaml,xamlx,xoml,xsd}] +indent_style=space +indent_size=2 +tab_width=2 diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bcf7e24 --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +bin/ +obj/ +/packages/ +riderModule.iml +/_ReSharper.Caches/ +.idea/ +.direnv/ +*.DotSettings.user +result diff --git a/DotnetRuntime.sln b/DotnetRuntime.sln new file mode 100644 index 0000000..b8421f8 --- /dev/null +++ b/DotnetRuntime.sln @@ -0,0 +1,29 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# +Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "WoofWare.DotnetRuntime", "WoofWare.DotnetRuntime\WoofWare.DotnetRuntime.fsproj", "{5A19255D-8235-44B2-AC33-ECC33DA0D28C}" +EndProject +Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "WoofWare.DotnetRuntime.Test", "WoofWare.DotnetRuntime.Test\WoofWare.DotnetRuntime.Test.fsproj", "{BB6B58B5-3D61-4628-8C5E-9300011FA9BA}" +EndProject +Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "WoofWare.DotnetRuntime.App", "WoofWare.DotnetRuntime.App\WoofWare.DotnetRuntime.App.fsproj", "{03D35F0B-AA7E-41B6-BC74-3DF37BBC76B5}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {5A19255D-8235-44B2-AC33-ECC33DA0D28C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5A19255D-8235-44B2-AC33-ECC33DA0D28C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5A19255D-8235-44B2-AC33-ECC33DA0D28C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5A19255D-8235-44B2-AC33-ECC33DA0D28C}.Release|Any CPU.Build.0 = Release|Any CPU + {BB6B58B5-3D61-4628-8C5E-9300011FA9BA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BB6B58B5-3D61-4628-8C5E-9300011FA9BA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BB6B58B5-3D61-4628-8C5E-9300011FA9BA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BB6B58B5-3D61-4628-8C5E-9300011FA9BA}.Release|Any CPU.Build.0 = Release|Any CPU + {03D35F0B-AA7E-41B6-BC74-3DF37BBC76B5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {03D35F0B-AA7E-41B6-BC74-3DF37BBC76B5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {03D35F0B-AA7E-41B6-BC74-3DF37BBC76B5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {03D35F0B-AA7E-41B6-BC74-3DF37BBC76B5}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/WoofWare.DotnetRuntime.App/Program.fs b/WoofWare.DotnetRuntime.App/Program.fs new file mode 100644 index 0000000..fe82c7c --- /dev/null +++ b/WoofWare.DotnetRuntime.App/Program.fs @@ -0,0 +1,11 @@ +namespace WoofWare.DotnetRuntime + +module Program = + let reallyMain (argv : string[]) : int = 0 + + [] + let main argv = + try + reallyMain argv + with _ -> + reraise () diff --git a/WoofWare.DotnetRuntime.App/WoofWare.DotnetRuntime.App.fsproj b/WoofWare.DotnetRuntime.App/WoofWare.DotnetRuntime.App.fsproj new file mode 100644 index 0000000..aa59b24 --- /dev/null +++ b/WoofWare.DotnetRuntime.App/WoofWare.DotnetRuntime.App.fsproj @@ -0,0 +1,18 @@ + + + + net8.0 + Exe + + + + + + + + + + + + + diff --git a/WoofWare.DotnetRuntime.Test/TestThing.fs b/WoofWare.DotnetRuntime.Test/TestThing.fs new file mode 100644 index 0000000..903fa55 --- /dev/null +++ b/WoofWare.DotnetRuntime.Test/TestThing.fs @@ -0,0 +1,9 @@ +namespace WoofWare.DotnetRuntime.Test + +open FsUnitTyped +open NUnit.Framework + +[] +module TestThing = + [] + let ``foo is a thing`` () = 1 |> shouldEqual 1 diff --git a/WoofWare.DotnetRuntime.Test/WoofWare.DotnetRuntime.Test.fsproj b/WoofWare.DotnetRuntime.Test/WoofWare.DotnetRuntime.Test.fsproj new file mode 100644 index 0000000..a643810 --- /dev/null +++ b/WoofWare.DotnetRuntime.Test/WoofWare.DotnetRuntime.Test.fsproj @@ -0,0 +1,28 @@ + + + + net9.0 + false + Exe + true + true + true + + + + + + + + + + + + + + + + + + + diff --git a/WoofWare.DotnetRuntime/Domain.fs b/WoofWare.DotnetRuntime/Domain.fs new file mode 100644 index 0000000..f3a00e3 --- /dev/null +++ b/WoofWare.DotnetRuntime/Domain.fs @@ -0,0 +1,3 @@ +namespace WoofWare.DotnetRuntime + +type MsIlInstruction = | Something diff --git a/WoofWare.DotnetRuntime/WoofWare.DotnetRuntime.fsproj b/WoofWare.DotnetRuntime/WoofWare.DotnetRuntime.fsproj new file mode 100644 index 0000000..671dc8d --- /dev/null +++ b/WoofWare.DotnetRuntime/WoofWare.DotnetRuntime.fsproj @@ -0,0 +1,11 @@ + + + + net8.0 + + + + + + + diff --git a/dotnet-tools.json b/dotnet-tools.json new file mode 100644 index 0000000..fda17c5 --- /dev/null +++ b/dotnet-tools.json @@ -0,0 +1,18 @@ +{ + "version": 1, + "isRoot": true, + "tools": { + "fantomas": { + "version": "7.0.0", + "commands": [ + "fantomas" + ] + }, + "fsharp-analyzers": { + "version": "0.28.0", + "commands": [ + "fsharp-analyzers" + ] + } + } +} \ No newline at end of file diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..150211c --- /dev/null +++ b/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1739419412, + "narHash": "sha256-NCWZQg4DbYVFWg+MOFrxWRaVsLA7yvRWAf6o0xPR1hI=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "2d55b4c1531187926c2a423f6940b3b1301399b5", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..123809b --- /dev/null +++ b/flake.nix @@ -0,0 +1,72 @@ +{ + description = "A .NET runtime."; + + inputs = { + flake-utils.url = "github:numtide/flake-utils"; + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + }; + + outputs = { + nixpkgs, + flake-utils, + ... + }: + flake-utils.lib.eachDefaultSystem (system: let + pkgs = nixpkgs.legacyPackages.${system}; + pname = "WoofWare.DotnetRuntime"; + dotnet-sdk = pkgs.dotnetCorePackages.sdk_9_0; + dotnet-runtime = pkgs.dotnetCorePackages.runtime_9_0; + version = "0.1"; + dotnetTool = dllOverride: toolName: toolVersion: hash: + pkgs.stdenvNoCC.mkDerivation rec { + name = toolName; + version = toolVersion; + nativeBuildInputs = [pkgs.makeWrapper]; + src = pkgs.fetchNuGet { + pname = name; + version = version; + hash = hash; + installPhase = ''mkdir -p $out/bin && cp -r tools/net*/any/* $out/bin''; + }; + installPhase = let + dll = + if isNull dllOverride + then name + else dllOverride; + in + # fsharp-analyzers requires the .NET SDK at runtime, so we use that instead of dotnet-runtime. + '' + runHook preInstall + mkdir -p "$out/lib" + cp -r ./bin/* "$out/lib" + makeWrapper "${dotnet-sdk}/bin/dotnet" "$out/bin/${name}" --set DOTNET_HOST_PATH "${dotnet-sdk}/bin/dotnet" --add-flags "$out/lib/${dll}.dll" + runHook postInstall + ''; + }; + in { + packages = let + deps = builtins.fromJSON (builtins.readFile ./nix/deps.json); + in { + fantomas = dotnetTool null "fantomas" (builtins.fromJSON (builtins.readFile ./.config/dotnet-tools.json)).tools.fantomas.version (builtins.head (builtins.filter (elem: elem.pname == "fantomas") deps)).hash; + fsharp-analyzers = dotnetTool "FSharp.Analyzers.Cli" "fsharp-analyzers" (builtins.fromJSON (builtins.readFile ./.config/dotnet-tools.json)).tools.fsharp-analyzers.version (builtins.head (builtins.filter (elem: elem.pname == "fsharp-analyzers") deps)).hash; + default = pkgs.buildDotnetModule { + inherit pname version dotnet-sdk dotnet-runtime; + name = "WoofWare.DotnetRuntime"; + src = ./.; + projectFile = "./WoofWare.DotnetRuntime/WoofWare.DotnetRuntime.fsproj"; + testProjectFile = "./WoofWare.DotnetRuntime.Test/WoofWare.DotnetRuntime.Test.fsproj"; + nugetDeps = ./nix/deps.json; # `nix build .#default.fetch-deps && ./result nix/deps.json` + doCheck = true; + }; + }; + devShell = pkgs.mkShell { + buildInputs = [dotnet-sdk]; + DOTNET_CLI_TELEMETRY_OPTOUT = "1"; + packages = [ + pkgs.alejandra + pkgs.nodePackages.markdown-link-check + pkgs.shellcheck + ]; + }; + }); +} diff --git a/nix/deps.json b/nix/deps.json new file mode 100644 index 0000000..97254dc --- /dev/null +++ b/nix/deps.json @@ -0,0 +1,177 @@ +[ + { + "pname": "fantomas", + "version": "7.0.0", + "hash": "sha256-v4bXmvjZOYxl5RSIHuqVfDzBQdRz5SrmzZtD6SeEYTY=" + }, + { + "pname": "fsharp-analyzers", + "version": "0.28.0", + "hash": "sha256-BqGk9MzHHA3oRPNfWuANcM1YELsdhzWI+kLF4mUDUx8=" + }, + { + "pname": "FSharp.Core", + "version": "5.0.2", + "hash": "sha256-YOoosLEiszPsOOaNAkWhFGU04JJKDOFVoA/ggrZMN10=" + }, + { + "pname": "FsUnit", + "version": "7.0.1", + "hash": "sha256-K85CIdxMeFSHEKZk6heIXp/oFjWAn7dBILKrw49pJUY=" + }, + { + "pname": "Microsoft.ApplicationInsights", + "version": "2.22.0", + "hash": "sha256-mUQ63atpT00r49ca50uZu2YCiLg3yd6r3HzTryqcuEA=" + }, + { + "pname": "Microsoft.AspNetCore.App.Ref", + "version": "8.0.12", + "hash": "sha256-9vCc5s7n5pvBYmews03YT2fc5F+A04y+9xu7cH0G+z0=" + }, + { + "pname": "Microsoft.AspNetCore.App.Runtime.linux-arm64", + "version": "8.0.12", + "hash": "sha256-WhX6VTJnKkdq6hHZcqyEzr/cwowQwbRAVWZvJjkgMhA=" + }, + { + "pname": "Microsoft.AspNetCore.App.Runtime.linux-x64", + "version": "8.0.12", + "hash": "sha256-tGAZAojcagIs+0xV2H85d2iLzanPZzAj8921JkFymNg=" + }, + { + "pname": "Microsoft.AspNetCore.App.Runtime.osx-arm64", + "version": "8.0.12", + "hash": "sha256-eDbOjy0Jyj3GmivEVr2Kg1b7k1njDQ9+7FGo/1jaBSk=" + }, + { + "pname": "Microsoft.AspNetCore.App.Runtime.osx-x64", + "version": "8.0.12", + "hash": "sha256-P7gJnRkTZT0+xx+VOjn0MX/CURjk/JdT5ArGC6mQ3Qw=" + }, + { + "pname": "Microsoft.CodeCoverage", + "version": "17.13.0", + "hash": "sha256-GKrIxeyQo5Az1mztfQgea1kGtJwonnNOrXK/0ULfu8o=" + }, + { + "pname": "Microsoft.NET.Test.Sdk", + "version": "17.13.0", + "hash": "sha256-sc2wvyV8cGm1FrNP2GGHEI584RCvRPu15erYCsgw5QY=" + }, + { + "pname": "Microsoft.NETCore.App.Host.linux-arm64", + "version": "8.0.12", + "hash": "sha256-FxHbBnQcGj7FXvpo3T25KG7owZNfxe4bJ2FDbsED8UQ=" + }, + { + "pname": "Microsoft.NETCore.App.Host.linux-x64", + "version": "8.0.12", + "hash": "sha256-zwtDPg/f/X905aVWwnipeCljGrZkTKkxrwTVvLu/FQY=" + }, + { + "pname": "Microsoft.NETCore.App.Host.osx-arm64", + "version": "8.0.12", + "hash": "sha256-rbs2nngORjRplfNKsmkXp9Uyo2XVVTxId5eLFF25ySs=" + }, + { + "pname": "Microsoft.NETCore.App.Host.osx-x64", + "version": "8.0.12", + "hash": "sha256-IuB3if/6rnQXkVYjtqr0HWcKWqeVNwQkkIeZlGKEvTQ=" + }, + { + "pname": "Microsoft.NETCore.App.Ref", + "version": "8.0.12", + "hash": "sha256-smRZuC/xOZiyZ8WUL/DmRjYFunbtySfS4NSTeqk0Q7c=" + }, + { + "pname": "Microsoft.NETCore.App.Runtime.linux-arm64", + "version": "8.0.12", + "hash": "sha256-PdIdrO1m4ZJS1tYAs4g0NIC2QmZeAD3iP5mNN53dWkM=" + }, + { + "pname": "Microsoft.NETCore.App.Runtime.linux-x64", + "version": "8.0.12", + "hash": "sha256-/d/xDBsCqANQO1Bp9ABY93RQRxfLVbFnTL7tQcT/UGo=" + }, + { + "pname": "Microsoft.NETCore.App.Runtime.osx-arm64", + "version": "8.0.12", + "hash": "sha256-bZom1Ip4QgtyfdkCZ7PGbArlu1fJuJmjjsCYJi7c3FY=" + }, + { + "pname": "Microsoft.NETCore.App.Runtime.osx-x64", + "version": "8.0.12", + "hash": "sha256-ku5+oEL8NsZp4vlyBbWTOdroicrWoY7BYRzx8WM9X7g=" + }, + { + "pname": "Microsoft.Testing.Extensions.Telemetry", + "version": "1.5.3", + "hash": "sha256-bIXwPSa3jkr2b6xINOqMUs6/uj/r4oVFM7xq3uVIZDU=" + }, + { + "pname": "Microsoft.Testing.Extensions.TrxReport.Abstractions", + "version": "1.5.3", + "hash": "sha256-IfMRfcyaIKEMRtx326ICKtinDBEfGw/Sv8ZHawJ96Yc=" + }, + { + "pname": "Microsoft.Testing.Extensions.VSTestBridge", + "version": "1.5.3", + "hash": "sha256-XpM/yFjhLSsuzyDV+xKubs4V1zVVYiV05E0+N4S1h0g=" + }, + { + "pname": "Microsoft.Testing.Platform", + "version": "1.5.3", + "hash": "sha256-y61Iih6w5D79dmrj2V675mcaeIiHoj1HSa1FRit2BLM=" + }, + { + "pname": "Microsoft.Testing.Platform.MSBuild", + "version": "1.5.3", + "hash": "sha256-YspvjE5Jfi587TAfsvfDVJXNrFOkx1B3y1CKV6m7YLY=" + }, + { + "pname": "Microsoft.TestPlatform.ObjectModel", + "version": "17.12.0", + "hash": "sha256-3XBHBSuCxggAIlHXmKNQNlPqMqwFlM952Av6RrLw1/w=" + }, + { + "pname": "Microsoft.TestPlatform.ObjectModel", + "version": "17.13.0", + "hash": "sha256-6S0fjfj8vA+h6dJVNwLi6oZhYDO/I/6hBZaq2VTW+Uk=" + }, + { + "pname": "Microsoft.TestPlatform.TestHost", + "version": "17.13.0", + "hash": "sha256-L/CJzou7dhmShUgXq3aXL3CaLTJll17Q+JY2DBdUUpo=" + }, + { + "pname": "Newtonsoft.Json", + "version": "13.0.1", + "hash": "sha256-K2tSVW4n4beRPzPu3rlVaBEMdGvWSv/3Q1fxaDh4Mjo=" + }, + { + "pname": "NUnit", + "version": "4.0.1", + "hash": "sha256-jd1CD5nHVXkpvBNpVDJcJyfTggCHLyDBySVSvtrA8Uk=" + }, + { + "pname": "NUnit", + "version": "4.3.2", + "hash": "sha256-0RWe8uFoxYp6qhPlDDEghOMcKJgyw2ybvEoAqBLebeE=" + }, + { + "pname": "NUnit3TestAdapter", + "version": "5.0.0", + "hash": "sha256-7jZM4qAbIzne3AcdFfMbvbgogqpxvVe6q2S7Ls8xQy0=" + }, + { + "pname": "System.Diagnostics.DiagnosticSource", + "version": "5.0.0", + "hash": "sha256-6mW3N6FvcdNH/pB58pl+pFSCGWgyaP4hfVtC/SMWDV4=" + }, + { + "pname": "System.Reflection.Metadata", + "version": "1.6.0", + "hash": "sha256-JJfgaPav7UfEh4yRAQdGhLZF1brr0tUWPl6qmfNWq/E=" + } +]