예제 #1
0
        public MethodCollector(string csProjPath, IEnumerable <string> conditinalSymbols, Action <string> logger)
        {
            this.csProjPath = csProjPath;
            var compilation = PseudoCompilation.CreateFromProjectAsync(new[] { csProjPath }, conditinalSymbols.ToArray(), CancellationToken.None).GetAwaiter().GetResult();

            this.typeReferences = new ReferenceSymbols(compilation, logger);

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

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

            hubInterfaces = bothInterfaces
                            .Where(x => x.AllInterfaces.Any(y => y.ApproximatelyEqual(typeReferences.IStreamingHubMarker)))
                            .Where(x => !x.ConstructedFrom.ApproximatelyEqual(this.typeReferences.IStreamingHub))
                            .Distinct()
                            .ToArray();
        }
 public static Task <CSharpCompilation> CreateFromProjectAsync(string[] csprojs, string[] preprocessorSymbols, CancellationToken cancellationToken)
 {
     return(PseudoCompilation.CreateFromProjectAsync(csprojs, preprocessorSymbols, cancellationToken));
 }