From ddd6374c72e347ff9a927e4bc90e8f1f769b53db Mon Sep 17 00:00:00 2001 From: Patrick Stevens <3138005+Smaug123@users.noreply.github.com> Date: Mon, 30 Jun 2025 22:15:33 +0100 Subject: [PATCH] More corelib (#76) --- CLAUDE.md | 2 ++ WoofWare.PawPrint.Domain/TypeInfo.fs | 4 ++++ WoofWare.PawPrint/Corelib.fs | 24 ++++++++++++++++++++++++ 3 files changed, 30 insertions(+) diff --git a/CLAUDE.md b/CLAUDE.md index 624e79f..ed9cb0c 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -81,7 +81,9 @@ dotnet publish --self-contained --runtime-id osx-arm64 CSharpExample/ && dotnet * Functions should be fully type-annotated, to give the most helpful error messages on type mismatches. * Generally, prefer to fully-qualify discriminated union cases in `match` statements. +* ALWAYS fully-qualify enum cases when constructing them and matching on them (e.g., `PrimitiveType.Int16` not `Int16`). * When writing a "TODO" `failwith`, specify in the error message what the condition is that triggers the failure, so that a failing run can easily be traced back to its cause. +* If a field name begins with an underscore (like `_LoadedAssemblies`), do not mutate it directly. Only mutate it via whatever intermediate methods have been defined for that purpose (like `WithLoadedAssembly`). ### Development Workflow diff --git a/WoofWare.PawPrint.Domain/TypeInfo.fs b/WoofWare.PawPrint.Domain/TypeInfo.fs index 37d33dd..b7fcedc 100644 --- a/WoofWare.PawPrint.Domain/TypeInfo.fs +++ b/WoofWare.PawPrint.Domain/TypeInfo.fs @@ -141,6 +141,10 @@ type BaseClassTypes<'corelib> = RuntimeFieldHandle : TypeInfo RuntimeTypeHandle : TypeInfo RuntimeType : TypeInfo + Void : TypeInfo + TypedReference : TypeInfo + IntPtr : TypeInfo + UIntPtr : TypeInfo } [] diff --git a/WoofWare.PawPrint/Corelib.fs b/WoofWare.PawPrint/Corelib.fs index cbdbe19..7fef4ce 100644 --- a/WoofWare.PawPrint/Corelib.fs +++ b/WoofWare.PawPrint/Corelib.fs @@ -114,6 +114,26 @@ module Corelib = |> Seq.choose (fun (KeyValue (_, v)) -> if v.Name = "RuntimeFieldHandle" then Some v else None) |> Seq.exactlyOne + let voidType = + corelib.TypeDefs + |> Seq.choose (fun (KeyValue (_, v)) -> if v.Name = "Void" then Some v else None) + |> Seq.exactlyOne + + let typedReferenceType = + corelib.TypeDefs + |> Seq.choose (fun (KeyValue (_, v)) -> if v.Name = "TypedReference" then Some v else None) + |> Seq.exactlyOne + + let intPtrType = + corelib.TypeDefs + |> Seq.choose (fun (KeyValue (_, v)) -> if v.Name = "IntPtr" then Some v else None) + |> Seq.exactlyOne + + let uintPtrType = + corelib.TypeDefs + |> Seq.choose (fun (KeyValue (_, v)) -> if v.Name = "UIntPtr" then Some v else None) + |> Seq.exactlyOne + { Corelib = corelib String = stringType @@ -138,4 +158,8 @@ module Corelib = RuntimeMethodHandle = runtimeMethodHandleType RuntimeFieldHandle = runtimeFieldHandleType RuntimeType = runtimeTypeType + Void = voidType + TypedReference = typedReferenceType + IntPtr = intPtrType + UIntPtr = uintPtrType }