File tree Expand file tree Collapse file tree 2 files changed +5
-2
lines changed
examples/transport-aot-example
src/Elastic.Transport/Extensions Expand file tree Collapse file tree 2 files changed +5
-2
lines changed Original file line number Diff line number Diff line change 88 <Nullable >enable</Nullable >
99 <PublishAot >true</PublishAot >
1010 <TrimmerSingleWarn >false</TrimmerSingleWarn >
11+ <WarningsAsErrors >true</WarningsAsErrors >
1112 </PropertyGroup >
1213
1314 <ItemGroup >
Original file line number Diff line number Diff line change 44
55using System ;
66using System . Collections . Generic ;
7+ using System . Diagnostics . CodeAnalysis ;
78using System . Globalization ;
89using System . IO ;
910using System . Linq ;
@@ -14,9 +15,10 @@ namespace Elastic.Transport.Extensions;
1415
1516internal static class EnumExtensions
1617{
17- public static string GetEnumName ( this Enum e )
18+ public static string GetEnumName < [ DynamicallyAccessedMembers ( DynamicallyAccessedMemberTypes . PublicFields ) ] T > ( this T e )
19+ where T : Enum
1820 {
19- var attributes = e . GetType ( ) . GetField ( e . ToString ( ) ) ? . GetCustomAttributes ( typeof ( EnumMemberAttribute ) , false ) ;
21+ var attributes = typeof ( T ) . GetField ( e . ToString ( ) ) ? . GetCustomAttributes ( typeof ( EnumMemberAttribute ) , false ) ;
2022 if ( attributes is null || attributes . Length == 0 )
2123 return e . ToString ( ) ;
2224
You can’t perform that action at this time.
0 commit comments