RF0302: Generic parameter needs MustBeVariant
Your T is forwarded to an API requiring a Variant-compatible parameter without the annotation.
For a C# project using Reckfell.NET.Sdk 1.0.0. Fix the first build error first: later messages may be a consequence.
Cause
Your T is forwarded to an API requiring a Variant-compatible parameter without the annotation.
Fix
Add MustBeVariant to the T declaration. This is an analyzer rule, not an arbitrary-object serializer or a CLR where constraint.
Failing example
Save the file in a test C# project and run dotnet build. This version intentionally fails to build.
Example.cs
using Reckfell;
namespace DiagnosticExamples.RF0302;
public static class Example { public static Variant Pack<T>(T value) => Variant.From<T>(value); }Expected messages: RF0302.
Working version
Replace the failing version with these files; do not keep both declarations in the project.
Example.cs
using Reckfell;
namespace DiagnosticExamples.RF0302;
public static class Example { public static Variant Pack<[MustBeVariant] T>(T value) => Variant.From<T>(value); }Result
Pack<int>(7) returns Variant.Type.Int with value 7. Calling Pack<DateTime> remains an RF0301 error.
Related material
Reckfell Engine documentationBack to top ↑