Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
waleswood opened this issue Dec 7, 2024 · 1 comment

Comments

@waleswood
Copy link
Contributor

描述一下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

@lianglj
Copy link

lianglj commented Dec 7, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants