public MocklisTypesForSymbols(SemanticModel semanticModel, ClassDeclarationSyntax classDeclaration, MocklisSymbols mocklisSymbols, bool nullableContextEnabled) { _semanticModel = semanticModel; _classDeclaration = classDeclaration; _mocklisSymbols = mocklisSymbols; _nullableContextEnabled = nullableContextEnabled; _typeParameterNameSubstitutions = null; }
public static ClassDeclarationSyntax UpdateMocklisClass(SemanticModel semanticModel, ClassDeclarationSyntax classDecl, MocklisSymbols mocklisSymbols, bool nullableContextEnabled) { var typesForSymbols = new MocklisTypesForSymbols(semanticModel, classDecl, mocklisSymbols, nullableContextEnabled); var populator = new MocklisClassPopulator(typesForSymbols, semanticModel, classDecl, mocklisSymbols); return(classDecl.WithMembers(F.List(populator.GenerateMembers())) .WithOpenBraceToken(F.Token(SyntaxKind.OpenBraceToken).WithTrailingTrivia(Comments)) .WithCloseBraceToken(F.Token(SyntaxKind.CloseBraceToken)) .WithAdditionalAnnotations(Formatter.Annotation) .WithAttributeLists(AddOrUpdateCodeGeneratedAttribute(typesForSymbols, semanticModel, mocklisSymbols, classDecl.AttributeLists))); }
private MocklisTypesForSymbols(SemanticModel semanticModel, ClassDeclarationSyntax classDeclaration, MocklisSymbols mocklisSymbols, INamedTypeSymbol classSymbol, IMethodSymbol methodSymbol, bool nullableContextEnabled) { _semanticModel = semanticModel; _classDeclaration = classDeclaration; _mocklisSymbols = mocklisSymbols; _typeParameterNameSubstitutions = new Dictionary <string, string>(); _nullableContextEnabled = nullableContextEnabled; Uniquifier t = new Uniquifier(classSymbol.TypeParameters.Select(tp => tp.Name)); foreach (var methodTypeParameter in methodSymbol.TypeParameters) { string uniqueName = t.GetUniqueName(methodTypeParameter.Name); _typeParameterNameSubstitutions[methodTypeParameter.Name] = uniqueName; } }
private static SyntaxList <AttributeListSyntax> AddOrUpdateCodeGeneratedAttribute(MocklisTypesForSymbols typesForSymbols, SemanticModel semanticModel, MocklisSymbols mocklisSymbols, in SyntaxList <AttributeListSyntax> classDeclAttributeLists)