From 7627edbef735251b37d916968f9bdecee36d8ce9 Mon Sep 17 00:00:00 2001 From: lookbusy1344 <3680611+lookbusy1344@users.noreply.github.com> Date: Mon, 9 Oct 2023 12:37:03 +0100 Subject: [PATCH] Moving the reflection based prototype into a separate folder --- Reflection example/Program.cs | 11 +++++++++++ Reflection example/README.md | 12 ++++++++++++ .../ValueEquality.cs | 14 ++------------ 3 files changed, 25 insertions(+), 12 deletions(-) create mode 100644 Reflection example/Program.cs create mode 100644 Reflection example/README.md rename Using reflection.txt => Reflection example/ValueEquality.cs (93%) diff --git a/Reflection example/Program.cs b/Reflection example/Program.cs new file mode 100644 index 0000000..73b25f1 --- /dev/null +++ b/Reflection example/Program.cs @@ -0,0 +1,11 @@ +namespace ExampleApp; + +internal static class Program +{ + private static void Main() + { + JS_Tools.ValueEquality.CheckAssembly(); + + // rest of your code goes here + } +} diff --git a/Reflection example/README.md b/Reflection example/README.md new file mode 100644 index 0000000..0bfec04 --- /dev/null +++ b/Reflection example/README.md @@ -0,0 +1,12 @@ +# Reflection based prototype + +This is some earlier work on using reflection at runtime to search for problematic records. Use the Roslyn code analyser in preference to this. + +Call the method once at the start of your `main()` method. The code is DEBUG mode only, and is not compiled in RELEASE mode. In `main` add: + +``` +JS_Tools.ValueEquality.CheckAssembly(); + +``` + +It will throw a `ValueEqualityException` if any problems are detected. diff --git a/Using reflection.txt b/Reflection example/ValueEquality.cs similarity index 93% rename from Using reflection.txt rename to Reflection example/ValueEquality.cs index da8b436..ca7ec04 100644 --- a/Using reflection.txt +++ b/Reflection example/ValueEquality.cs @@ -1,14 +1,4 @@ -/* - -This was an initial attempt using reflection. It checks records at runtime, so its not ideal. - -To use call ValueEquality.CheckAssembly() at the start of your main() method - -The code only runs in DEBUG builds - -*/ - -#if DEBUG +#if DEBUG using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; @@ -22,7 +12,7 @@ namespace JS_Tools; // warnings related to AOT compile, that doesnt support reflection. But this doesnt matter for Debug builds // and code is turned off in Release build -// #pragma warning disable IDE0079, IL2070, IL2026, IL3050 +#pragma warning disable IDE0079, IL2070, IL2026, IL3050 /// /// Debug-only class to check that all record for value semantics