Skip to content

收集实体信息时,如果字段类型是枚举定义,枚举继承 ushort,则会报错 #304

@waleswood

Description

@waleswood

描述一下BUG

定义一个枚举,继承 ushort

public enum EGenderType : ushort
{
     = 0,
     = 1,
    未知性别 = 2,
    未说明性别 = 9
}

重现步骤

  1. 启动,在收集实体信息时报错
System.InvalidCastException
  HResult=0x80004002
  Message=Unable to cast object of type 'AuthCenter.Core.Enums.EGenderType' to type 'System.Int32'.
  Source=System.Linq
  StackTrace:
   在 System.Linq.Enumerable.<CastIterator>d__68`1.MoveNext() 在 /_/src/libraries/System.Linq/src/System/Linq/Cast.cs 中: 第 55 行
   在 System.Collections.Generic.LargeArrayBuilder`1.AddRange(IEnumerable`1 items) 在 /_/src/libraries/Common/src/System/Collections/Generic/LargeArrayBuilder.SpeedOpt.cs 中: 第 112 行
   在 System.Collections.Generic.EnumerableHelpers.ToArray[T](IEnumerable`1 source) 在 /_/src/libraries/Common/src/System/Collections/Generic/EnumerableHelpers.Linq.cs 中: 第 84 行
   在 OSharp.Authorization.EntityInfos.EntityInfoBase.<>c.<FromType>b__18_1(PropertyInfo property)
   在 System.Linq.Enumerable.WhereSelectArrayIterator`2.ToArray() 在 /_/src/libraries/System.Linq/src/System/Linq/Where.SpeedOpt.cs 中: 第 218 行
   在 OSharp.Authorization.EntityInfos.EntityInfoBase.FromType(Type entityType)
   在 OSharp.Authorization.EntityInfos.EntityInfoHandlerBase`2.Initialize()
   在 OSharp.Authorization.EntityInfos.EntityInfoPack.UsePack(IServiceProvider provider)
   在 Microsoft.AspNetCore.Builder.ApplicationBuilderExtensions.UseOSharp(WebApplication app)
   在 Schoolmate.Startup.Configure(WebApplication app) 在 D:\Workspace\QBN\Schoolmate\Schoolmate\Startup.cs 中: 第 62 行
   在 Program.<Main>$(String[] args) 在 D:\Workspace\QBN\Schoolmate\Schoolmate\Program.cs 中: 第 9 行 

期望行为

枚举转换时不应该粗暴的转成int

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions