11namespace FTMS . NET ;
2+
3+ using SourceGeneration . Reflection ;
24using System ;
35using System . Collections . Frozen ;
4- using System . Reflection ;
56
7+ [ SourceReflection ]
68public static class FtmsUuids
79{
810 private static readonly FrozenDictionary < Guid , string > allFieldsByUuid ;
@@ -26,6 +28,7 @@ public static class FtmsUuids
2628 public readonly static Guid RowerData = Guid . ParseExact ( "00002ad1-0000-1000-8000-00805f9b34fb" , "d" ) ;
2729 public readonly static Guid IndoorBikeData = Guid . ParseExact ( "00002ad2-0000-1000-8000-00805f9b34fb" , "d" ) ;
2830
31+ [ SourceReflection ]
2932 public static class IndoorBike
3033 {
3134 public static readonly Guid InstantaneousSpeed = new ( "765050cd-a033-4972-a71b-29c013c0845b" ) ;
@@ -49,12 +52,11 @@ static FtmsUuids()
4952 {
5053 var thisType = typeof ( FtmsUuids ) ;
5154 var guidType = typeof ( Guid ) ;
52- allFieldsByUuid = thisType . GetNestedTypes ( )
53- . Prepend ( thisType )
54- . SelectMany ( type => type
55- . GetFields ( BindingFlags . Static | BindingFlags . Public )
56- . Where ( f => f . FieldType == guidType ) )
57- . ToFrozenDictionary ( f => ( Guid ) f . GetValue ( null ) ! , f => f . Name ) ;
55+ allFieldsByUuid = SourceReflector . GetTypes ( )
56+ . SelectMany ( t => t . GetFieldsAndProperties ( )
57+ . Where ( fop => fop . IsStatic && fop . Accessibility == SourceAccessibility . Public )
58+ . Where ( fop => fop . MemberType == guidType ) )
59+ . ToFrozenDictionary ( fop => ( Guid ) fop . GetValue ( null ) ! , fop => fop . Name ) ;
5860 }
5961
6062 public static string GetName ( Guid uuid )
0 commit comments