Skip to content

Commit

Permalink
Moving the reflection based prototype into a separate folder
Browse files Browse the repository at this point in the history
  • Loading branch information
lookbusy1344 committed Oct 9, 2023
1 parent d340a62 commit 7627edb
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 12 deletions.
11 changes: 11 additions & 0 deletions Reflection example/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace ExampleApp;

internal static class Program
{
private static void Main()
{
JS_Tools.ValueEquality.CheckAssembly();

// rest of your code goes here
}
}
12 changes: 12 additions & 0 deletions Reflection example/README.md
Original file line number Diff line number Diff line change
@@ -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.
14 changes: 2 additions & 12 deletions Using reflection.txt → Reflection example/ValueEquality.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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

/// <summary>
/// Debug-only class to check that all record for value semantics
Expand Down

0 comments on commit 7627edb

Please sign in to comment.