@@ -16,15 +16,6 @@ namespace MongoDB.Analyzer.Core;
1616
1717internal sealed class TypesProcessor
1818{
19- private static readonly Dictionary < string , string > s_knownBsonTypes = new ( )
20- {
21- { "MongoDB.Bson.BsonDocument" , "BsonDocumentCustom123" } ,
22- { "MongoDB.Bson.BsonValue" , "BsonValueCustom123" } ,
23- { "MongoDB.Bson.BsonObjectId" , "BsonObjectIdCustom123" } ,
24- { "MongoDB.Bson.BsonType" , "BsonTypeCustom123" } ,
25- { "MongoDB.Bson.Serialization.Options.TimeSpanUnits" , "BsonTimeSpanCustom123" }
26- } ;
27-
2819 private readonly Dictionary < string , ( string NewName , MemberDeclarationSyntax NewDeclaration ) > _processedTypes ;
2920
3021 private int _nextTypeId = 0 ;
@@ -73,9 +64,9 @@ public string ProcessTypeSymbol(ITypeSymbol typeSymbol)
7364 }
7465
7566 var fullTypeName = GetFullName ( typeSymbol ) ;
76- if ( s_knownBsonTypes . TryGetValue ( fullTypeName , out var knowTypeName ) )
67+ if ( typeSymbol . IsSupportedBsonType ( ) )
7768 {
78- return ( knowTypeName , fullTypeName ) ;
69+ return ( typeSymbol . Name , fullTypeName ) ;
7970 }
8071
8172 if ( _processedTypes . TryGetValue ( fullTypeName , out var result ) )
@@ -236,7 +227,7 @@ private void GenerateFields(ITypeSymbol typeSymbol, List<MemberDeclarationSyntax
236227 var attributeLists = bsonAttributeList != null && bsonAttributeList . Attributes . AnySafe ( ) ?
237228 SyntaxFactory . List < AttributeListSyntax > ( SyntaxFactory . SingletonSeparatedList < AttributeListSyntax > ( bsonAttributeList ) ) :
238229 SyntaxFactory . List < AttributeListSyntax > ( ) ;
239-
230+
240231 var fieldDeclaration = SyntaxFactory . FieldDeclaration (
241232 attributeLists : attributeLists ,
242233 modifiers : SyntaxFactory . TokenList ( SyntaxFactory . Token ( SyntaxKind . PublicKeyword ) ) ,
@@ -349,7 +340,7 @@ private ExpressionSyntax GenerateExpressionFromBsonAttributeArgumentInfo(TypedCo
349340
350341 private ExpressionSyntax HandleEnumInBsonAttributeArgument ( object value , ITypeSymbol typeSymbol ) =>
351342 SyntaxFactoryUtilities . GetCastConstantExpression ( ProcessTypeSymbol ( typeSymbol ) , value ) ;
352-
343+
353344 private LiteralExpressionSyntax HandlePrimitiveInBsonAttributeArgument ( object value ) =>
354345 SyntaxFactoryUtilities . GetConstantExpression ( value ) ;
355346
0 commit comments