reckfellENGINE

RF0302: Generic parameter needs MustBeVariant

Your T is forwarded to an API requiring a Variant-compatible parameter without the annotation.

On this page

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
C#
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
C#
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.

All C# diagnostics · C# guide

Reckfell Engine documentationBack to top ↑
QUICK LINKSGetting startedEntity hierarchyC# & .NET 10Scenes and prefabs
Reckfell guides and full API K
reckfellENGINE
RECKFELL ACCOUNT

Sign in

Sign in to your Reckfell account.

One account for the entire Reckfell platform.