2
0
mirror of https://github.com/esiur/esiur-dotnet.git synced 2025-09-13 20:43:19 +00:00

DynamicMethod Nullable Events

This commit is contained in:
2022-04-01 15:47:19 +03:00
parent 20fcaba518
commit 2809d389bd
7 changed files with 293 additions and 234 deletions

View File

@@ -0,0 +1,27 @@
namespace System.Runtime.CompilerServices
{
[AttributeUsage(
AttributeTargets.Class |
AttributeTargets.Event |
AttributeTargets.Field |
AttributeTargets.GenericParameter |
AttributeTargets.Parameter |
AttributeTargets.Property |
AttributeTargets.ReturnValue,
AllowMultiple = false,
Inherited = false)]
public sealed class NullableAttribute : Attribute
{
public readonly byte[] Flags;
public readonly byte Flag;
public NullableAttribute(byte flag)
{
Flag = flag;// new byte[] { flag };
}
public NullableAttribute(byte[] flags)
{
Flags = flags;
}
}
}

View File

@@ -0,0 +1,19 @@
namespace System.Runtime.CompilerServices
{
[System.AttributeUsage(
AttributeTargets.Class |
AttributeTargets.Delegate |
AttributeTargets.Interface |
AttributeTargets.Method |
AttributeTargets.Struct,
AllowMultiple = false,
Inherited = false)]
public sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte flag)
{
Flag = flag;
}
}
}

View File

@@ -89,14 +89,20 @@ namespace Esiur.Data
public RepresentationType?[] SubTypes = new RepresentationType[3];
public static RepresentationType? FromType(Type type)
public static RepresentationType? FromType(Type type, bool forceNullable = false)
{
var nullType = System.Nullable.GetUnderlyingType(type);
var nullable = false;
if (nullType != null) {
type = nullType;
nullable = true;
var nullable = forceNullable;
if (!forceNullable)
{
var nullType = System.Nullable.GetUnderlyingType(type);
if (nullType != null)
{
type = nullType;
nullable = true;
}
}
if (type.IsGenericType)