예제 #1
0
        /// <summary>
        /// Looks for external types in the current compilation
        /// </summary>
        private void FindExternalTypes()
        {
            INamedTypeSymbol exterTypeExtrAttr = Compilation.GetTypeByMetadataName(typeof(ScriptObjectsAttribute).FullName);

            foreach (AttributeData attrData in Compilation.Assembly.GetAttributes())
            {
                if (attrData.AttributeClass.Equals(exterTypeExtrAttr))
                {
                    string targetPath = "";
                    for (int i = 0; i < attrData.ConstructorArguments.Length; i++)
                    {
                        TypedConstant typedConstant = attrData.ConstructorArguments[i];
                        if (typedConstant.Kind == TypedConstantKind.Primitive)
                        {
                            targetPath = typedConstant.Value as string;
                        }
                        else
                        {
                            foreach (TypedConstant oneTypeArg in typedConstant.Values)
                            {
                                INamedTypeSymbol type = oneTypeArg.Value as INamedTypeSymbol;

                                ParseContext context   = new ParseContext(Compilation, GetDocumentationProvider(type));
                                INamedType   namedType = RoslynType.CreateNamedType(type, context);
                                _visitor.VisitExternalType(namedType, targetPath);
                            }
                        }
                    }
                }
            }
        }