Initial commit

This commit is contained in:
Smaug123
2025-02-13 23:30:15 +00:00
commit a5a3d87ba9
15 changed files with 505 additions and 0 deletions

18
.config/dotnet-tools.json Normal file
View File

@@ -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"
]
}
}
}

40
.editorconfig Normal file
View File

@@ -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

1
.envrc Normal file
View File

@@ -0,0 +1 @@
use flake

9
.gitignore vendored Normal file
View File

@@ -0,0 +1,9 @@
bin/
obj/
/packages/
riderModule.iml
/_ReSharper.Caches/
.idea/
.direnv/
*.DotSettings.user
result

29
DotnetRuntime.sln Normal file
View File

@@ -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

View File

@@ -0,0 +1,11 @@
namespace WoofWare.DotnetRuntime
module Program =
let reallyMain (argv : string[]) : int = 0
[<EntryPoint>]
let main argv =
try
reallyMain argv
with _ ->
reraise ()

View File

@@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<OutputType>Exe</OutputType>
</PropertyGroup>
<ItemGroup>
<Compile Include="Program.fs"/>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="../WoofWare.DotnetRuntime/WoofWare.DotnetRuntime.fsproj"/>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,9 @@
namespace WoofWare.DotnetRuntime.Test
open FsUnitTyped
open NUnit.Framework
[<TestFixture>]
module TestThing =
[<Test>]
let ``foo is a thing`` () = 1 |> shouldEqual 1

View File

@@ -0,0 +1,28 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<IsPackable>false</IsPackable>
<OutputType>Exe</OutputType>
<IsTestProject>true</IsTestProject>
<TestingPlatformDotnetTestSupport>true</TestingPlatformDotnetTestSupport>
<EnableNUnitRunner>true</EnableNUnitRunner>
</PropertyGroup>
<ItemGroup>
<Compile Include="TestThing.fs"/>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="../WoofWare.DotnetRuntime/WoofWare.DotnetRuntime.fsproj"/>
</ItemGroup>
<ItemGroup>
<PackageReference Include="FsUnit" Version="7.0.1"/>
<PackageReference Include="NUnit3TestAdapter" Version="5.0.0"/>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.13.0"/>
<PackageReference Include="NUnit" Version="4.3.2"/>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,3 @@
namespace WoofWare.DotnetRuntime
type MsIlInstruction = | Something

View File

@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Compile Include="Domain.fs"/>
</ItemGroup>
</Project>

18
dotnet-tools.json Normal file
View File

@@ -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"
]
}
}
}

61
flake.lock generated Normal file
View File

@@ -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
}

72
flake.nix Normal file
View File

@@ -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
];
};
});
}

177
nix/deps.json Normal file
View File

@@ -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="
}
]