Esempio n. 1
0
        public MethodCollector(string csProjPath, IEnumerable <string> conditinalSymbols)
        {
            this.csProjPath = csProjPath;
            var compilation = RoslynExtensions.GetCompilationFromProject(csProjPath, conditinalSymbols.ToArray()).GetAwaiter().GetResult();

            this.typeReferences = new ReferenceSymbols(compilation);

            var bothInterfaces = compilation.GetNamedTypeSymbols()
                                 .Where(x => x.TypeKind == TypeKind.Interface)
                                 .Where(x =>
            {
                var all = x.AllInterfaces;
                if (all.Any(y => y == typeReferences.IServiceMarker) || all.Any(y => y == typeReferences.IStreamingHubMarker))
                {
                    return(true);
                }
                return(false);
            })
                                 .ToArray();

            serviceInterfaces = bothInterfaces
                                .Where(x => x.AllInterfaces.Any(y => y == typeReferences.IServiceMarker) && x.AllInterfaces.All(y => y != typeReferences.IStreamingHubMarker))
                                .Distinct()
                                .ToArray();

            hubInterfaces = bothInterfaces
                            .Where(x => x.AllInterfaces.Any(y => y == typeReferences.IStreamingHubMarker))
                            .Distinct()
                            .ToArray();
        }
Esempio n. 2
0
        public static async Task <MethodCollector> CreateCollector(string csProjPath, IEnumerable <string> conditinalSymbols,
                                                                   string framework, bool quiet)
        {
            MSBuildLocator.RegisterDefaults();

            var compilation = await RoslynExtensions.GetCompilationFromProject(csProjPath, framework, quiet,
                                                                               conditinalSymbols.ToArray());

            return(new MethodCollector(csProjPath, compilation));
        }
        public AssemblyAttributeCollector(string csProjPath, IEnumerable <string> conditinalSymbols)
        {
            this.csProjPath = csProjPath;
            var compilation = RoslynExtensions.GetCompilationFromProject(csProjPath, conditinalSymbols.ToArray()).GetAwaiter().GetResult();

            this.keyTupleMarker = compilation.GetTypeByMetadataName("ZeroFormatter.IKeyTuple");
            var marker = compilation.GetTypeByMetadataName(HintAttributeDefinition.FullName);

            var attributes = compilation.Assembly.GetAttributes();

            this.hintAttributes = attributes.Where(x => x.AttributeClass == marker).ToArray();
        }
Esempio n. 4
0
        public MethodCollector(string csProjPath, IEnumerable <string> conditinalSymbols)
        {
            this.csProjPath = csProjPath;
            var compilation = RoslynExtensions.GetCompilationFromProject(csProjPath, conditinalSymbols.ToArray()).GetAwaiter().GetResult();

            this.typeReferences = new ReferenceSymbols(compilation);

            var marker = compilation.GetTypeByMetadataName("MagicOnion.IServiceMarker");

            baseInterface = compilation.GetTypeByMetadataName("MagicOnion.IService`1");

            serviceTypes = compilation.GetNamedTypeSymbols()
                           .Where(t => t.AllInterfaces.Any(x => x == marker))
                           .ToArray();

            interfaces = serviceTypes
                         .Concat(serviceTypes.SelectMany(x => x.AllInterfaces))
                         .Distinct()
                         .Where(x => x != marker)
                         .Where(t => t != baseInterface)
                         .Where(x => !x.IsGenericType || x.ConstructedFrom != baseInterface)
                         .ToArray();
        }