C#: Annotate API with MustBeVariant
- Add MustBeVariant attribute to generic parameters that are used in a Variant context
This commit is contained in:
parent
9de0c73e45
commit
0a0c730805
3 changed files with 27 additions and 27 deletions
|
@ -45,7 +45,7 @@ public readonly partial struct Callable
|
|||
}
|
||||
|
||||
/// <inheritdoc cref="From(Action)"/>
|
||||
public static unsafe Callable From<T0>(
|
||||
public static unsafe Callable From<[MustBeVariant] T0>(
|
||||
Action<T0> action
|
||||
)
|
||||
{
|
||||
|
@ -64,7 +64,7 @@ public readonly partial struct Callable
|
|||
}
|
||||
|
||||
/// <inheritdoc cref="From(Action)"/>
|
||||
public static unsafe Callable From<T0, T1>(
|
||||
public static unsafe Callable From<[MustBeVariant] T0, [MustBeVariant] T1>(
|
||||
Action<T0, T1> action
|
||||
)
|
||||
{
|
||||
|
@ -84,7 +84,7 @@ public readonly partial struct Callable
|
|||
}
|
||||
|
||||
/// <inheritdoc cref="From(Action)"/>
|
||||
public static unsafe Callable From<T0, T1, T2>(
|
||||
public static unsafe Callable From<[MustBeVariant] T0, [MustBeVariant] T1, [MustBeVariant] T2>(
|
||||
Action<T0, T1, T2> action
|
||||
)
|
||||
{
|
||||
|
@ -105,7 +105,7 @@ public readonly partial struct Callable
|
|||
}
|
||||
|
||||
/// <inheritdoc cref="From(Action)"/>
|
||||
public static unsafe Callable From<T0, T1, T2, T3>(
|
||||
public static unsafe Callable From<[MustBeVariant] T0, [MustBeVariant] T1, [MustBeVariant] T2, [MustBeVariant] T3>(
|
||||
Action<T0, T1, T2, T3> action
|
||||
)
|
||||
{
|
||||
|
@ -127,7 +127,7 @@ public readonly partial struct Callable
|
|||
}
|
||||
|
||||
/// <inheritdoc cref="From(Action)"/>
|
||||
public static unsafe Callable From<T0, T1, T2, T3, T4>(
|
||||
public static unsafe Callable From<[MustBeVariant] T0, [MustBeVariant] T1, [MustBeVariant] T2, [MustBeVariant] T3, [MustBeVariant] T4>(
|
||||
Action<T0, T1, T2, T3, T4> action
|
||||
)
|
||||
{
|
||||
|
@ -150,7 +150,7 @@ public readonly partial struct Callable
|
|||
}
|
||||
|
||||
/// <inheritdoc cref="From(Action)"/>
|
||||
public static unsafe Callable From<T0, T1, T2, T3, T4, T5>(
|
||||
public static unsafe Callable From<[MustBeVariant] T0, [MustBeVariant] T1, [MustBeVariant] T2, [MustBeVariant] T3, [MustBeVariant] T4, [MustBeVariant] T5>(
|
||||
Action<T0, T1, T2, T3, T4, T5> action
|
||||
)
|
||||
{
|
||||
|
@ -174,7 +174,7 @@ public readonly partial struct Callable
|
|||
}
|
||||
|
||||
/// <inheritdoc cref="From(Action)"/>
|
||||
public static unsafe Callable From<T0, T1, T2, T3, T4, T5, T6>(
|
||||
public static unsafe Callable From<[MustBeVariant] T0, [MustBeVariant] T1, [MustBeVariant] T2, [MustBeVariant] T3, [MustBeVariant] T4, [MustBeVariant] T5, [MustBeVariant] T6>(
|
||||
Action<T0, T1, T2, T3, T4, T5, T6> action
|
||||
)
|
||||
{
|
||||
|
@ -199,7 +199,7 @@ public readonly partial struct Callable
|
|||
}
|
||||
|
||||
/// <inheritdoc cref="From(Action)"/>
|
||||
public static unsafe Callable From<T0, T1, T2, T3, T4, T5, T6, T7>(
|
||||
public static unsafe Callable From<[MustBeVariant] T0, [MustBeVariant] T1, [MustBeVariant] T2, [MustBeVariant] T3, [MustBeVariant] T4, [MustBeVariant] T5, [MustBeVariant] T6, [MustBeVariant] T7>(
|
||||
Action<T0, T1, T2, T3, T4, T5, T6, T7> action
|
||||
)
|
||||
{
|
||||
|
@ -225,7 +225,7 @@ public readonly partial struct Callable
|
|||
}
|
||||
|
||||
/// <inheritdoc cref="From(Action)"/>
|
||||
public static unsafe Callable From<T0, T1, T2, T3, T4, T5, T6, T7, T8>(
|
||||
public static unsafe Callable From<[MustBeVariant] T0, [MustBeVariant] T1, [MustBeVariant] T2, [MustBeVariant] T3, [MustBeVariant] T4, [MustBeVariant] T5, [MustBeVariant] T6, [MustBeVariant] T7, [MustBeVariant] T8>(
|
||||
Action<T0, T1, T2, T3, T4, T5, T6, T7, T8> action
|
||||
)
|
||||
{
|
||||
|
@ -255,7 +255,7 @@ public readonly partial struct Callable
|
|||
/// Constructs a new <see cref="Callable"/> for the given <paramref name="func"/>.
|
||||
/// </summary>
|
||||
/// <param name="func">Action method that will be called.</param>
|
||||
public static unsafe Callable From<TResult>(
|
||||
public static unsafe Callable From<[MustBeVariant] TResult>(
|
||||
Func<TResult> func
|
||||
)
|
||||
{
|
||||
|
@ -272,7 +272,7 @@ public readonly partial struct Callable
|
|||
}
|
||||
|
||||
/// <inheritdoc cref="From{TResult}(Func{TResult})"/>
|
||||
public static unsafe Callable From<T0, TResult>(
|
||||
public static unsafe Callable From<[MustBeVariant] T0, [MustBeVariant] TResult>(
|
||||
Func<T0, TResult> func
|
||||
)
|
||||
{
|
||||
|
@ -291,7 +291,7 @@ public readonly partial struct Callable
|
|||
}
|
||||
|
||||
/// <inheritdoc cref="From{TResult}(Func{TResult})"/>
|
||||
public static unsafe Callable From<T0, T1, TResult>(
|
||||
public static unsafe Callable From<[MustBeVariant] T0, [MustBeVariant] T1, [MustBeVariant] TResult>(
|
||||
Func<T0, T1, TResult> func
|
||||
)
|
||||
{
|
||||
|
@ -311,7 +311,7 @@ public readonly partial struct Callable
|
|||
}
|
||||
|
||||
/// <inheritdoc cref="From{TResult}(Func{TResult})"/>
|
||||
public static unsafe Callable From<T0, T1, T2, TResult>(
|
||||
public static unsafe Callable From<[MustBeVariant] T0, [MustBeVariant] T1, [MustBeVariant] T2, [MustBeVariant] TResult>(
|
||||
Func<T0, T1, T2, TResult> func
|
||||
)
|
||||
{
|
||||
|
@ -332,7 +332,7 @@ public readonly partial struct Callable
|
|||
}
|
||||
|
||||
/// <inheritdoc cref="From{TResult}(Func{TResult})"/>
|
||||
public static unsafe Callable From<T0, T1, T2, T3, TResult>(
|
||||
public static unsafe Callable From<[MustBeVariant] T0, [MustBeVariant] T1, [MustBeVariant] T2, [MustBeVariant] T3, [MustBeVariant] TResult>(
|
||||
Func<T0, T1, T2, T3, TResult> func
|
||||
)
|
||||
{
|
||||
|
@ -354,7 +354,7 @@ public readonly partial struct Callable
|
|||
}
|
||||
|
||||
/// <inheritdoc cref="From{TResult}(Func{TResult})"/>
|
||||
public static unsafe Callable From<T0, T1, T2, T3, T4, TResult>(
|
||||
public static unsafe Callable From<[MustBeVariant] T0, [MustBeVariant] T1, [MustBeVariant] T2, [MustBeVariant] T3, [MustBeVariant] T4, [MustBeVariant] TResult>(
|
||||
Func<T0, T1, T2, T3, T4, TResult> func
|
||||
)
|
||||
{
|
||||
|
@ -377,7 +377,7 @@ public readonly partial struct Callable
|
|||
}
|
||||
|
||||
/// <inheritdoc cref="From{TResult}(Func{TResult})"/>
|
||||
public static unsafe Callable From<T0, T1, T2, T3, T4, T5, TResult>(
|
||||
public static unsafe Callable From<[MustBeVariant] T0, [MustBeVariant] T1, [MustBeVariant] T2, [MustBeVariant] T3, [MustBeVariant] T4, [MustBeVariant] T5, [MustBeVariant] TResult>(
|
||||
Func<T0, T1, T2, T3, T4, T5, TResult> func
|
||||
)
|
||||
{
|
||||
|
@ -401,7 +401,7 @@ public readonly partial struct Callable
|
|||
}
|
||||
|
||||
/// <inheritdoc cref="From{TResult}(Func{TResult})"/>
|
||||
public static unsafe Callable From<T0, T1, T2, T3, T4, T5, T6, TResult>(
|
||||
public static unsafe Callable From<[MustBeVariant] T0, [MustBeVariant] T1, [MustBeVariant] T2, [MustBeVariant] T3, [MustBeVariant] T4, [MustBeVariant] T5, [MustBeVariant] T6, [MustBeVariant] TResult>(
|
||||
Func<T0, T1, T2, T3, T4, T5, T6, TResult> func
|
||||
)
|
||||
{
|
||||
|
@ -426,7 +426,7 @@ public readonly partial struct Callable
|
|||
}
|
||||
|
||||
/// <inheritdoc cref="From{TResult}(Func{TResult})"/>
|
||||
public static unsafe Callable From<T0, T1, T2, T3, T4, T5, T6, T7, TResult>(
|
||||
public static unsafe Callable From<[MustBeVariant] T0, [MustBeVariant] T1, [MustBeVariant] T2, [MustBeVariant] T3, [MustBeVariant] T4, [MustBeVariant] T5, [MustBeVariant] T6, [MustBeVariant] T7, [MustBeVariant] TResult>(
|
||||
Func<T0, T1, T2, T3, T4, T5, T6, T7, TResult> func
|
||||
)
|
||||
{
|
||||
|
@ -452,7 +452,7 @@ public readonly partial struct Callable
|
|||
}
|
||||
|
||||
/// <inheritdoc cref="From{TResult}(Func{TResult})"/>
|
||||
public static unsafe Callable From<T0, T1, T2, T3, T4, T5, T6, T7, T8, TResult>(
|
||||
public static unsafe Callable From<[MustBeVariant] T0, [MustBeVariant] T1, [MustBeVariant] T2, [MustBeVariant] T3, [MustBeVariant] T4, [MustBeVariant] T5, [MustBeVariant] T6, [MustBeVariant] T7, [MustBeVariant] T8, [MustBeVariant] TResult>(
|
||||
Func<T0, T1, T2, T3, T4, T5, T6, T7, T8, TResult> func
|
||||
)
|
||||
{
|
||||
|
|
|
@ -260,7 +260,7 @@ namespace Godot.NativeInterop
|
|||
=> from != null ? CreateFromArray((godot_array)from.NativeValue) : default;
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static godot_variant CreateFromArray<T>(Array<T>? from)
|
||||
public static godot_variant CreateFromArray<[MustBeVariant] T>(Array<T>? from)
|
||||
=> from != null ? CreateFromArray((godot_array)((Collections.Array)from).NativeValue) : default;
|
||||
|
||||
public static godot_variant CreateFromDictionary(godot_dictionary from)
|
||||
|
@ -274,7 +274,7 @@ namespace Godot.NativeInterop
|
|||
=> from != null ? CreateFromDictionary((godot_dictionary)from.NativeValue) : default;
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static godot_variant CreateFromDictionary<TKey, TValue>(Dictionary<TKey, TValue>? from)
|
||||
public static godot_variant CreateFromDictionary<[MustBeVariant] TKey, [MustBeVariant] TValue>(Dictionary<TKey, TValue>? from)
|
||||
=> from != null ? CreateFromDictionary((godot_dictionary)((Dictionary)from).NativeValue) : default;
|
||||
|
||||
public static godot_variant CreateFromStringName(godot_string_name from)
|
||||
|
@ -526,7 +526,7 @@ namespace Godot.NativeInterop
|
|||
=> Collections.Array.CreateTakingOwnershipOfDisposableValue(ConvertToNativeArray(p_var));
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Array<T> ConvertToArray<T>(in godot_variant p_var)
|
||||
public static Array<T> ConvertToArray<[MustBeVariant] T>(in godot_variant p_var)
|
||||
=> Array<T>.CreateTakingOwnershipOfDisposableValue(ConvertToNativeArray(p_var));
|
||||
|
||||
public static godot_dictionary ConvertToNativeDictionary(in godot_variant p_var)
|
||||
|
@ -539,7 +539,7 @@ namespace Godot.NativeInterop
|
|||
=> Dictionary.CreateTakingOwnershipOfDisposableValue(ConvertToNativeDictionary(p_var));
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Dictionary<TKey, TValue> ConvertToDictionary<TKey, TValue>(in godot_variant p_var)
|
||||
public static Dictionary<TKey, TValue> ConvertToDictionary<[MustBeVariant] TKey, [MustBeVariant] TValue>(in godot_variant p_var)
|
||||
=> Dictionary<TKey, TValue>.CreateTakingOwnershipOfDisposableValue(ConvertToNativeDictionary(p_var));
|
||||
|
||||
public static byte[] ConvertAsPackedByteArrayToSystemArray(in godot_variant p_var)
|
||||
|
|
|
@ -328,11 +328,11 @@ public partial struct Variant : IDisposable
|
|||
VariantUtils.ConvertToSystemArrayOfGodotObject<T>((godot_variant)NativeVar);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public Collections.Dictionary<TKey, TValue> AsGodotDictionary<TKey, TValue>() =>
|
||||
public Collections.Dictionary<TKey, TValue> AsGodotDictionary<[MustBeVariant] TKey, [MustBeVariant] TValue>() =>
|
||||
VariantUtils.ConvertToDictionary<TKey, TValue>((godot_variant)NativeVar);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public Collections.Array<T> AsGodotArray<T>() =>
|
||||
public Collections.Array<T> AsGodotArray<[MustBeVariant] T>() =>
|
||||
VariantUtils.ConvertToArray<T>((godot_variant)NativeVar);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
|
@ -647,11 +647,11 @@ public partial struct Variant : IDisposable
|
|||
public static Variant CreateFrom(Godot.Object[] from) => from;
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Variant CreateFrom<TKey, TValue>(Collections.Dictionary<TKey, TValue> from) =>
|
||||
public static Variant CreateFrom<[MustBeVariant] TKey, [MustBeVariant] TValue>(Collections.Dictionary<TKey, TValue> from) =>
|
||||
CreateTakingOwnershipOfDisposableValue(VariantUtils.CreateFromDictionary(from));
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Variant CreateFrom<T>(Collections.Array<T> from) =>
|
||||
public static Variant CreateFrom<[MustBeVariant] T>(Collections.Array<T> from) =>
|
||||
CreateTakingOwnershipOfDisposableValue(VariantUtils.CreateFromArray(from));
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
|
|
Loading…
Reference in a new issue