Exemplo n.º 1
0
 public MocklisTypesForSymbols(SemanticModel semanticModel, ClassDeclarationSyntax classDeclaration, MocklisSymbols mocklisSymbols,
                               bool nullableContextEnabled)
 {
     _semanticModel                  = semanticModel;
     _classDeclaration               = classDeclaration;
     _mocklisSymbols                 = mocklisSymbols;
     _nullableContextEnabled         = nullableContextEnabled;
     _typeParameterNameSubstitutions = null;
 }
Exemplo n.º 2
0
        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)));
        }
Exemplo n.º 3
0
        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;
            }
        }
Exemplo n.º 4
0
 private static SyntaxList <AttributeListSyntax> AddOrUpdateCodeGeneratedAttribute(MocklisTypesForSymbols typesForSymbols,
                                                                                   SemanticModel semanticModel, MocklisSymbols mocklisSymbols, in SyntaxList <AttributeListSyntax> classDeclAttributeLists)