1010
1111namespace schema . util . types ;
1212
13- public class TypeInfoParser {
13+ public static class TypeInfoParser {
1414 public enum ParseStatus {
1515 SUCCESS ,
1616 NOT_A_FIELD_OR_PROPERTY_OR_METHOD ,
1717 NOT_IMPLEMENTED ,
1818 }
1919
20- public IEnumerable < ( ParseStatus , ISymbol ) > ParseMembers (
20+ public static IEnumerable < ( ParseStatus , ISymbol ) > ParseMembers (
2121 INamedTypeSymbol containerSymbol ) {
2222 foreach ( var memberSymbol in containerSymbol . GetInstanceMembers ( ) ) {
2323 // Tries to parse the type to get info about it
24- var parseStatus = this . ParseMember ( memberSymbol ) ;
24+ var parseStatus = ParseMember ( memberSymbol ) ;
2525 yield return ( parseStatus , memberSymbol ) ;
2626 }
2727 }
2828
29- public ParseStatus ParseMember ( ISymbol memberSymbol ) {
29+ public static ParseStatus ParseMember ( ISymbol memberSymbol ) {
3030 if ( memberSymbol is IMethodSymbol ) {
3131 return ParseStatus . SUCCESS ;
3232 }
@@ -44,51 +44,22 @@ public ParseStatus ParseMember(ISymbol memberSymbol) {
4444 return ParseStatus . NOT_A_FIELD_OR_PROPERTY_OR_METHOD ;
4545 }
4646
47- return this . ParseTypeSymbol ( memberTypeSymbol , isReadonly ) ;
47+ return ParseTypeSymbol ( memberTypeSymbol , isReadonly ) ;
4848 }
4949
50- public ParseStatus ParseTypeSymbol ( ITypeSymbol typeSymbol , bool isReadonly ) {
51- this . ParseNullable_ ( ref typeSymbol ) ;
52-
53- if ( typeSymbol . IsPrimitive ( out var primitiveType ) ) {
54- switch ( primitiveType ) {
55- case SchemaPrimitiveType . BOOLEAN : {
56- return ParseStatus . SUCCESS ;
57- }
58- case SchemaPrimitiveType . BYTE :
59- case SchemaPrimitiveType . SBYTE :
60- case SchemaPrimitiveType . INT16 :
61- case SchemaPrimitiveType . UINT16 :
62- case SchemaPrimitiveType . INT32 :
63- case SchemaPrimitiveType . UINT32 :
64- case SchemaPrimitiveType . INT64 :
65- case SchemaPrimitiveType . UINT64 : {
66- return ParseStatus . SUCCESS ;
67- }
68- case SchemaPrimitiveType . SN8 :
69- case SchemaPrimitiveType . UN8 :
70- case SchemaPrimitiveType . SN16 :
71- case SchemaPrimitiveType . UN16 :
72- case SchemaPrimitiveType . SINGLE :
73- case SchemaPrimitiveType . DOUBLE : {
74- return ParseStatus . SUCCESS ;
75- }
76- case SchemaPrimitiveType . CHAR : {
77- return ParseStatus . SUCCESS ;
78- }
79- case SchemaPrimitiveType . ENUM : {
80- return ParseStatus . SUCCESS ;
81- }
82- default : throw new ArgumentOutOfRangeException ( ) ;
83- }
50+ public static ParseStatus ParseTypeSymbol ( ITypeSymbol typeSymbol , bool isReadonly ) {
51+ ParseNullable_ ( ref typeSymbol ) ;
52+
53+ if ( typeSymbol . IsPrimitive ( out _ ) ) {
54+ return ParseStatus . SUCCESS ;
8455 }
8556
8657 if ( typeSymbol . IsString ( ) ) {
8758 return ParseStatus . SUCCESS ;
8859 }
8960
9061 if ( typeSymbol . IsSequence ( out var elementTypeV2 , out var sequenceType ) ) {
91- var elementParseStatus = this . ParseTypeSymbol (
62+ var elementParseStatus = ParseTypeSymbol (
9263 elementTypeV2 ,
9364 sequenceType . IsReadOnly ( ) ) ;
9465 if ( elementParseStatus != ParseStatus . SUCCESS ) {
@@ -112,7 +83,7 @@ public ParseStatus ParseTypeSymbol(ITypeSymbol typeSymbol, bool isReadonly) {
11283 return ParseStatus . NOT_IMPLEMENTED ;
11384 }
11485
115- private bool GetTypeOfMember_ (
86+ private static bool GetTypeOfMember_ (
11687 ISymbol memberSymbol ,
11788 out ITypeSymbol memberTypeSymbol ,
11889 out bool isMemberReadonly ) {
@@ -135,7 +106,7 @@ private bool GetTypeOfMember_(
135106 }
136107 }
137108
138- private void ParseNullable_ ( ref ITypeSymbol typeSymbol ) {
109+ private static void ParseNullable_ ( ref ITypeSymbol typeSymbol ) {
139110 if ( ! typeSymbol . IsType ( typeof ( Nullable < > ) ) ) {
140111 return ;
141112 }
0 commit comments