Skip to content

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

Closed

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.

Activity

  1. self-assigned this
    on Jun 25, 2024
  2. added this to the 9.0.0 milestone on Jun 25, 2024
  3. added a commit that references this issue on Jul 3, 2024
    a7b0cb1
  4. removed their assignment
    on Jul 3, 2024
  5. self-assigned this
    on Jul 3, 2024
  6. added 3 commits that reference this issue on Jul 3, 2024
    1af8af3
    1c1e19e
    7cb0b4d
  7. added a commit that references this issue on Jul 9, 2024
    4840bc3
  8. modified the milestones: 9.0.0, on Aug 21, 2024
  9. modified the milestones: , 9.0.0 on Oct 12, 2024
  10. added theissue type on Jun 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions