Create() public method

public Create ( Microsoft.CodeAnalysis.CSharp.Syntax.ClassDeclarationSyntax classDeclaration ) : ClassWithSourceCode
classDeclaration Microsoft.CodeAnalysis.CSharp.Syntax.ClassDeclarationSyntax
return ClassWithSourceCode
 public override void VisitSimpleBaseType(SimpleBaseTypeSyntax node)
 {
     var baseClassType = node.Type;
     var baseClassSymbolInfo = _semantic.GetSymbolInfo(baseClassType);
     if (baseClassSymbolInfo.Symbol != null)
     {
         var baseClassTypeSymbol = (ITypeSymbol)baseClassSymbolInfo.Symbol;
         // skip interfaces as base types (since they do not have an implementation
         // their methods will always be overridden by the mixins)
         if (baseClassTypeSymbol.TypeKind == TypeKind.Interface)
             return;
         var classFactory = new ClassFactory(_semantic);
         _subClass.BaseClass = classFactory.Create(baseClassTypeSymbol);
     }
 }
示例#2
0
        public override void VisitVariableDeclarator(VariableDeclaratorSyntax node)
        {
            // we take only the first declaration we found
            // so if this field definition has more than one variable declaration,
            // skip after the first one
            if (MixinReference != null)
                return;
            var fieldSymbol = (IFieldSymbol)_semantic.GetDeclaredSymbol(node);
            var typeOfField = fieldSymbol.Type;
            // type could not be resolved => return here
            if (typeOfField.TypeKind == TypeKind.Error)
                return;
            
            // also ignore native types (like int, string, double etc...)
            // we identify them by checking if the types are declared in the runtime itself
            // if yes, they are system types and we will skip them
            var module = typeOfField.ContainingModule;
            if (module != null && module.Name == CommonLanguageRuntimeLibrary)
                return;          

            var classFactory = new ClassFactory(_semantic);
            // create the mixin reference, that is the name of the field and the type the field references
            MixinReference = new MixinReference(fieldSymbol.Name, classFactory.Create(typeOfField));
        }