Thanks to visit codestin.com
Credit goes to github.com

Skip to content

AOT/Compiled model: Somewhat complex entity with enums produces compiled model that contains AOT warnings #34057

@maumar

Description

@maumar

Entity:

public class MyEntity1
{
    public int Id { get; set; }
    public string Name1 { get; set; }
    public string Name2 { get; set; }
    public string Name3 { get; set; }
    public string Name4 { get; set; }
    public string Name5 { get; set; }

    public int Number1 { get; set; }
    public int Number2 { get; set; }
    public int Number3 { get; set; }

    public DateTime Date1 { get; set; }
    public DateTime Date2 { get; set; }
    public DateTime Date3 { get; set; }
    public MyEnum1 Enum1 { get; set; }
    public MyEnum1 Enum2 { get; set; }

    public int[] PrimAr1 { get; set; }
    public string[] PrimAr2 { get; set; }


    public List<MyRoot1> Owned { get; set; }
}

public enum MyEnum1
{
    Foo,
    Bar,
    Baz,
}

public class MyRoot1
{
    public string Prop1 { get; set; }
    public string Prop2 { get; set; }
    public string Prop3 { get; set; }
    public string Prop4 { get; set; }
    public string Prop5 { get; set; }

    public Branch1 Nested { get; set; }
}

public class Branch1
{
    public int Nst1 { get; set; }
    public int Nst2 { get; set; }
    public int Nst3 { get; set; }
    public int Nst4 { get; set; }
}

compiled model part:

            enum1.TypeMapping = IntTypeMapping.Default.Clone(
                comparer: new ValueComparer<MyEnum0>(
                    (MyEnum0 v1, MyEnum0 v2) => object.Equals((object)v1, (object)v2),
                    (MyEnum0 v) => ((object)v).GetHashCode(),
                    (MyEnum0 v) => v),
                keyComparer: new ValueComparer<MyEnum0>(
                    (MyEnum0 v1, MyEnum0 v2) => object.Equals((object)v1, (object)v2),
                    (MyEnum0 v) => ((object)v).GetHashCode(),
                    (MyEnum0 v) => v),
                providerValueComparer: new ValueComparer<int>(
                    (int v1, int v2) => v1 == v2,
                    (int v) => v,
                    (int v) => v),
                converter: new ValueConverter<MyEnum0, int>(
                    (MyEnum0 value) => (int)value,
                    (int value) => (MyEnum0)value),
                jsonValueReaderWriter: new JsonConvertedValueReaderWriter<MyEnum0, int>(
                    JsonInt32ReaderWriter.Instance,
                    new ValueConverter<MyEnum0, int>(
                        (MyEnum0 value) => (int)value,
                        (int value) => (MyEnum0)value)));

error:

Warning IL3050: AotPublishSample.Generated.MyEntity0EntityType.Create(RuntimeModel,RuntimeEntityType): Using member 'System.Enum.GetValues(Type)' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. It might not be possible to create an array of the enum type at runtime. Use the GetValues overload or the GetValuesAsUnderlyingType method instead.

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions