Add MustBeVariant attribute and analyzer
- MustBeVariant attribute can be used to enforce that generic types must be a marshable from/to Variant. - Also renames all diagnostic ids to be valid unicode identifiers.
This commit is contained in:
parent
d0a2a4c981
commit
6468f9b37c
14 changed files with 227 additions and 18 deletions
|
|
@ -483,7 +483,7 @@ namespace Godot.Collections
|
|||
/// <typeparam name="T">The type of the array.</typeparam>
|
||||
[SuppressMessage("ReSharper", "RedundantExtendsListEntry")]
|
||||
[SuppressMessage("Naming", "CA1710", MessageId = "Identifiers should have correct suffix")]
|
||||
public sealed class Array<T> :
|
||||
public sealed class Array<[MustBeVariant] T> :
|
||||
IList<T>,
|
||||
IReadOnlyList<T>,
|
||||
ICollection<T>,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,11 @@
|
|||
using System;
|
||||
|
||||
namespace Godot
|
||||
{
|
||||
/// <summary>
|
||||
/// Attribute that restricts generic type parameters to be only types
|
||||
/// that can be marshaled from/to a <see cref="Variant"/>.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.GenericParameter)]
|
||||
public class MustBeVariantAttribute : Attribute { }
|
||||
}
|
||||
|
|
@ -352,7 +352,7 @@ namespace Godot.Collections
|
|||
/// </summary>
|
||||
/// <typeparam name="TKey">The type of the dictionary's keys.</typeparam>
|
||||
/// <typeparam name="TValue">The type of the dictionary's values.</typeparam>
|
||||
public class Dictionary<TKey, TValue> :
|
||||
public class Dictionary<[MustBeVariant] TKey, [MustBeVariant] TValue> :
|
||||
IDictionary<TKey, TValue>,
|
||||
IReadOnlyDictionary<TKey, TValue>
|
||||
{
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@
|
|||
<Compile Include="Core\Attributes\ExportCategoryAttribute.cs" />
|
||||
<Compile Include="Core\Attributes\ExportGroupAttribute.cs" />
|
||||
<Compile Include="Core\Attributes\ExportSubgroupAttribute.cs" />
|
||||
<Compile Include="Core\Attributes\MustBeVariantAttribute.cs" />
|
||||
<Compile Include="Core\Attributes\RPCAttribute.cs" />
|
||||
<Compile Include="Core\Attributes\ScriptPathAttribute.cs" />
|
||||
<Compile Include="Core\Attributes\SignalAttribute.cs" />
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue