Ejemplo n.º 1
0
        public static bool IsValidPMixinFile(this CSharpFile file)
        {
            //skip code behind files.
            if (file.FileName.FullPath.EndsWith(Constants.PMixinFileExtension,
                                                StringComparison.InvariantCultureIgnoreCase))
            {
                return(false);
            }

            var partialClasses = file.SyntaxTree.GetPartialClasses();
            var resolver       = file.CreateResolver();

            return(partialClasses.Any(
                       c =>
            {
                var resolvedClass = resolver.Resolve(c);

                if (resolvedClass.IsError)
                {
                    return false;
                }

                return
                resolvedClass.Type.GetAttributes()
                .Any(x => x.AttributeType.Implements <IPMixinAttribute>());
            }));
        }
        public static IEnumerable <IType> ResolveTypes(this CSharpFile file)
        {
            var resolver = file.CreateResolver();

            return(file.SyntaxTree.GetClassDefinitions()
                   .Select(x => resolver.Resolve(x))
                   .Where(x => !x.IsError)
                   .Select(x => x.Type)
                   .ToArray());
        }