コード例 #1
0
        public async Task when_action_then_assert()
        {
            var workspace   = MSBuildWorkspace.Create();
            var projectPath = new FileInfo(@"..\..\..\Clide\Clide.csproj").FullName;

            await workspace.OpenSolutionAsync(@"..\..\..\Clide.sln");

            var project = workspace.CurrentSolution.Projects.Where(x =>
                                                                   string.Equals(x.FilePath, projectPath, StringComparison.InvariantCultureIgnoreCase))
                          .FirstOrDefault();

            var compilation = await project.GetCompilationAsync();

            Assert.NotNull(project);

            var observableAttribute = compilation
                                      .GetSymbolsWithName(name => name == ComponentAttribute, SymbolFilter.Type)
                                      .FirstOrDefault(a => a.ContainingNamespace.Name == "Clide");

            var observables = new List <INamedTypeSymbol>();

            foreach (var document in project.Documents)
            {
                var syntax = await document.GetSyntaxTreeAsync();

                var semanticModel = compilation.GetSemanticModel(syntax);
                var visitor       = new ComponentVisitor(semanticModel, observableAttribute);
                visitor.Visit(syntax.GetRoot());

                observables.AddRange(visitor.observables);
            }

            foreach (var observable in observables)
            {
                var observableInterfaces = observable.AllInterfaces.Where(i =>
                                                                          i.IsGenericType && i.ConstructedFrom.ToString() == "System.IObservable<T>").ToList();

                Console.WriteLine(observableInterfaces.Count);
            }

            //var task = Mock.Of<Task>
            //var project =
        }
コード例 #2
0
        public BuildComponentInspectorData(BuildConfigurationInspectorData config, IBuildComponent value)
        {
            m_Config = config;

            ComponentType         = value.GetType();
            ComponentSource       = config.GetComponentSource(ComponentType);
            IsComponentPresent    = config.HasComponent(ComponentType);
            IsComponentInherited  = config.IsComponentInherited(ComponentType);
            IsComponentOverriding = config.IsComponentOverriding(ComponentType);
            IsComponentUsed       = config.IsComponentUsed(ComponentType);
            ConfigHasPipeline     = config.HasPipeline;
            ComponentName         = ObjectNames.NicifyVariableName(ComponentType.Name);

            var visitor = new ComponentVisitor();

            PropertyContainer.Visit(ref value, visitor);
            FieldNames = visitor.FieldNames;

            IsPipelineComponent = typeof(IBuildPipelineComponent).IsAssignableFrom(ComponentType);
            IsTagComponent      = FieldNames.Length == 0;
            Icon = Resources.BuildComponentIcon;

            Value = value;
        }
コード例 #3
0
ファイル: ExportsGeneratorSpec.cs プロジェクト: kzu/clide
		public async Task when_action_then_assert()
		{
			var workspace = MSBuildWorkspace.Create();
			var projectPath = new FileInfo(@"..\..\..\Clide\Clide.csproj").FullName;

			await workspace.OpenSolutionAsync(@"..\..\..\Clide.sln");

			var project = workspace.CurrentSolution.Projects.Where(x =>
			   string.Equals(x.FilePath, projectPath, StringComparison.InvariantCultureIgnoreCase))
				.FirstOrDefault();

			var compilation = await project.GetCompilationAsync();

			Assert.NotNull(project);

			var observableAttribute = compilation
				.GetSymbolsWithName(name => name == ComponentAttribute, SymbolFilter.Type)
				.FirstOrDefault(a => a.ContainingNamespace.Name == "Clide");

			var observables = new List<INamedTypeSymbol>();

			foreach (var document in project.Documents)
			{
				var syntax = await document.GetSyntaxTreeAsync();
				var semanticModel = compilation.GetSemanticModel(syntax);
				var visitor = new ComponentVisitor(semanticModel, observableAttribute);
				visitor.Visit(syntax.GetRoot());

				observables.AddRange(visitor.observables);
			}

			foreach (var observable in observables)
			{
				var observableInterfaces = observable.AllInterfaces.Where(i =>
					i.IsGenericType && i.ConstructedFrom.ToString() == "System.IObservable<T>").ToList();

				Console.WriteLine(observableInterfaces.Count);
			}

			//var task = Mock.Of<Task>
			//var project = 
		}