当前位置: 首页>>代码示例>>C#>>正文


C# CodeAnalysis.Solution类代码示例

本文整理汇总了C#中Microsoft.CodeAnalysis.Solution的典型用法代码示例。如果您正苦于以下问题:C# Solution类的具体用法?C# Solution怎么用?C# Solution使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Solution类属于Microsoft.CodeAnalysis命名空间,在下文中一共展示了Solution类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: PreviewChanges

 public Solution PreviewChanges(
     string title,
     string helpString,
     string description,
     string topLevelName,
     Glyph topLevelGlyph,
     Solution newSolution,
     Solution oldSolution,
     bool showCheckBoxes = true)
 {
     var engine = new PreviewEngine(
         title,
         helpString,
         description,
         topLevelName,
         topLevelGlyph,
         newSolution,
         oldSolution,
         _componentModel,
         _imageService,
         showCheckBoxes);
     _previewChanges.PreviewChanges(engine);
     engine.CloseWorkspace();
     return engine.FinalSolution;
 }
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:25,代码来源:PreviewService.cs

示例2: RaiseWorkspaceChangedEventAsync

        protected Task RaiseWorkspaceChangedEventAsync(WorkspaceChangeKind kind, Solution oldSolution, Solution newSolution, ProjectId projectId = null, DocumentId documentId = null)
        {
            if (newSolution == null)
            {
                throw new ArgumentNullException("newSolution");
            }

            if (oldSolution == newSolution)
            {
                return SpecializedTasks.EmptyTask;
            }

            if (projectId == null && documentId != null)
            {
                projectId = documentId.ProjectId;
            }

            var handlers = this.eventMap.GetEventHandlers<EventHandler<WorkspaceChangeEventArgs>>(WorkspaceChangeEventName);
            if (handlers.Length > 0)
            {
                return this.ScheduleTask(() =>
                {
                    var args = new WorkspaceChangeEventArgs(kind, oldSolution, newSolution, projectId, documentId);
                    foreach (var handler in handlers)
                    {
                        handler(this, args);
                    }
                }, "Workspace.WorkspaceChanged");
            }
            else
            {
                return SpecializedTasks.EmptyTask;
            }
        }
开发者ID:EkardNT,项目名称:Roslyn,代码行数:34,代码来源:Workspace_Events.cs

示例3: LoadInitialSemanticVersions

 public void LoadInitialSemanticVersions(Solution solution)
 {
     foreach (var project in solution.Projects)
     {
         LoadInitialSemanticVersions(project);
     }
 }
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:7,代码来源:SemanticVersionTrackingService.cs

示例4: SolutionGenerator

        public SolutionGenerator(
            string projectFilePath,
            string commandLineArguments,
            string outputAssemblyPath,
            string solutionSourceFolder,
            string solutionDestinationFolder,
            string serverPath,
            string networkShare)
        {
            this.ProjectFilePath = projectFilePath;
            string projectName = Path.GetFileNameWithoutExtension(projectFilePath);
            string language = projectFilePath.EndsWith(".vbproj", StringComparison.OrdinalIgnoreCase) ?
                LanguageNames.VisualBasic : LanguageNames.CSharp;
            this.SolutionSourceFolder = solutionSourceFolder;
            this.SolutionDestinationFolder = solutionDestinationFolder;
            this.ServerPath = serverPath;
            this.NetworkShare = networkShare;
            string projectSourceFolder = Path.GetDirectoryName(projectFilePath);

            this.solution = CreateSolution(
                commandLineArguments,
                projectName,
                language,
                projectSourceFolder,
                outputAssemblyPath);
        }
开发者ID:akrisiun,项目名称:SourceBrowser,代码行数:26,代码来源:SolutionGenerator.cs

示例5: GetGraphAsync

        public async Task<GraphBuilder> GetGraphAsync(Solution solution, IGraphContext context, CancellationToken cancellationToken)
        {
            var graphBuilder = await GraphBuilder.CreateForInputNodesAsync(solution, context.InputNodes, cancellationToken).ConfigureAwait(false);

            foreach (var node in context.InputNodes)
            {
                var symbol = graphBuilder.GetSymbol(node);
                var references = await SymbolFinder.FindReferencesAsync(symbol, solution, cancellationToken).ConfigureAwait(false);

                foreach (var reference in references)
                {
                    var referencedSymbol = reference.Definition;
                    var projectId = graphBuilder.GetContextProject(node).Id;

                    var allLocations = referencedSymbol.Locations.Concat(reference.Locations.Select(r => r.Location))
                                                                 .Where(l => l != null && l.IsInSource);

                    foreach (var location in allLocations)
                    {
                        var locationNode = GetLocationNode(referencedSymbol, location, context, projectId, cancellationToken);
                        graphBuilder.AddLink(node, CodeLinkCategories.SourceReferences, locationNode);
                    }
                }
            }

            return graphBuilder;
        }
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:27,代码来源:IsUsedByGraphQuery.cs

示例6: TestListCategorizer

 public TestListCategorizer(string pathToVsmdiFile, string pathToSolution)
 {
     _workspace = MSBuildWorkspace.Create();
     _solution = _workspace.OpenSolutionAsync(pathToSolution).Result;
     var vsmdiParser = new VsmdiParser();
     _testlists = vsmdiParser.ReadFile(pathToVsmdiFile);
 }
开发者ID:bremnes,项目名称:TagUnitTestFromTestlist,代码行数:7,代码来源:TestListCategorizer.cs

示例7: AnalyzeCoupling

        // TODO Refactor
        private IEnumerable<ClassCouplingMetrics> AnalyzeCoupling(Solution solution)
        {
            var documents = _documentWalker.GetAllDocumentsFromSolution(solution);
            foreach (var document in documents)
            {
                var typeDeclarations = _documentWalker.GetNodesFromDocument<TypeDeclarationSyntax>(document);
                var semanticModel = document.GetSemanticModelAsync().Result;

                foreach (var type in typeDeclarations)
                {
                    var classCouplingMetrics = new ClassCouplingMetrics(type.Identifier.Text);
                    var invocations = type.DescendantNodes().OfType<InvocationExpressionSyntax>();
                    foreach (var invocation in invocations)
                    {
                        classCouplingMetrics.TotalAmountCalls ++;
                        string nameSpace;
                        if (IsInternal(invocation, semanticModel, out nameSpace))
                        {
                            classCouplingMetrics.TotalInternCalls++;
                        }
                        else
                        {
                            classCouplingMetrics.TotalExternCalls++;
                            classCouplingMetrics.AddExternCall(nameSpace);
                        }
                    }
                    yield return classCouplingMetrics;
                }
            }
        }
开发者ID:birksimon,项目名称:CodeAnalysis,代码行数:31,代码来源:CouplingInspector.cs

示例8: FindMethodSymbolAndProjectInSolution

 public static ProjectMethod FindMethodSymbolAndProjectInSolution(Solution solution, MethodDescriptor methodDescriptor)
 {
     ProjectMethod res;
     res.Method = null;
     res.Project = null;
     foreach (var project in solution.Projects)
     {
         // Alternative method using SymbolFinder, it only works with methods in the solution
         // Discarded by the moment
         //var methodDeclarations = SymbolFinder.FindDeclarationsAsync(project, methodDescriptor.MethodName,false).Result;
         //methodDeclarations = methodDeclarations.Where(ms => methodDescriptor.SameAsMethodSymbom(ms as IMethodSymbol));
         //if (methodDeclarations.Count() > 0)
         //{
         //    return methodDeclarations.First() as IMethodSymbol;
         //}
         //else
         //{
         // My own method
         var method = FindMethodSymbolInProject(methodDescriptor, project);
         if (method != null)
         {
             res.Project = project;
             res.Method = method;
             return res;
         }
         //}
     }
     return res;
 }
开发者ID:TubaKayaDev,项目名称:Call-Graph-Builder-DotNet,代码行数:29,代码来源:RoslynSymbolFactory.cs

示例9: AnalyseSolutionAsync

        private async Task<List<ProjectAnalysisResult>> AnalyseSolutionAsync(Solution solution, ImmutableArray<DiagnosticAnalyzer> analyzers, Configuration configuration)
        {
            var ruleIds = analyzers
                .SelectMany(a => a.SupportedDiagnostics.Select(d => d.Id))
                .Where(d => !_configuration.DisabledDiagnostics.Contains(d))
                .ToImmutableHashSet();

            var projectAnalysisTasks = solution.Projects
                // First, Running analysis
                .Select(p => new { Project = p, Task = AnalyzeProjectAsync(p, analyzers) })
                .ToList()
                // Then we need to print all the results
                .Select(p => new { Project = p.Project, Task = p.Task.ContinueWith(t =>
                    {
                        var diagnostics = t.Result.Where(d => ruleIds.Contains(d.Id)).ToImmutableArray();
                        if (configuration.RunInfoLevelDiagnostics)
                        {
                            diagnostics = diagnostics.Where(d => d.Severity != DiagnosticSeverity.Info).ToImmutableArray();
                        }
                        LogDiagnostics(p.Project, diagnostics);

                        return t;
                    }).Unwrap()})
                .ToList();

            // And need to wait when all the analysis and printing tasks would be finished
            await Task.WhenAll(projectAnalysisTasks.Select(p => p.Task));

            // And only after now we can build the result
            var result =
                projectAnalysisTasks
                .Select(r => new ProjectAnalysisResult(r.Project, r.Task.Result.Where(d => ruleIds.Contains(d.Id)).ToImmutableArray())).ToList();

            return result;
        }
开发者ID:SergeyTeplyakov,项目名称:ErrorProne.NET,代码行数:35,代码来源:AnalyzerRunner.cs

示例10: SolutionAnalayzer

 public SolutionAnalayzer(string solutionPath)
 {
     _workspace = MSBuildWorkspace.Create();
     _workspace.WorkspaceFailed += _workspace_WorkspaceFailed;
     _solution = _workspace.OpenSolutionAsync(solutionPath).Result;
     _refsourceLinkProvider.Init();
 }
开发者ID:george2giga,项目名称:SourceBrowser,代码行数:7,代码来源:SolutionAnalyzer.cs

示例11: DisplayReferencedSymbols

 public override void DisplayReferencedSymbols(Solution solution, IEnumerable<ReferencedSymbol> referencedSymbols)
 {
     foreach (var presenter in _referencedSymbolsPresenters)
     {
         presenter.Value.DisplayResult(solution, referencedSymbols);
     }
 }
开发者ID:xyh413,项目名称:roslyn,代码行数:7,代码来源:RoslynVisualStudioWorkspace.cs

示例12: MemberTarget

 public MemberTarget(SourceTextContainer textContainer, ISymbol memberIdentifier, Project project, Solution solution)
 {
     _textContainer = textContainer;
     _memberIdentifier = memberIdentifier;
     _project = project;
     _solution = solution;
 }
开发者ID:AlexEyler,项目名称:InheritanceMargin,代码行数:7,代码来源:RoslynMemberTarget.cs

示例13: RenameFields

            private async Task<Solution> RenameFields(Solution solution, DocumentId documentId, int count, CancellationToken cancellationToken)
            {
                Solution oldSolution = null;
                for (int i = 0; i < count; i++)
                {
                    oldSolution = solution;

                    var semanticModel = await solution.GetDocument(documentId).GetSemanticModelAsync(cancellationToken);
                    var root = await semanticModel.SyntaxTree.GetRootAsync(cancellationToken);
                    var declaration = root.GetAnnotatedNodes(s_markerAnnotation).ElementAt(i);

                    // Make note, VB represents "fields" marked as "WithEvents" as properties, so don't be
                    // tempted to treat this as a IFieldSymbol. We only need the name, so ISymbol is enough.
                    var fieldSymbol = semanticModel.GetDeclaredSymbol(declaration, cancellationToken);
                    var newName = GetNewFieldName(fieldSymbol);

                    // Can happen with pathologically bad field names like _
                    if (newName == fieldSymbol.Name)
                    {
                        continue;
                    }

                    solution = await Renamer.RenameSymbolAsync(solution, fieldSymbol, newName, solution.Workspace.Options, cancellationToken).ConfigureAwait(false);
                    solution = await CleanSolutionAsync(solution, oldSolution, cancellationToken);
                }

                return solution;
            }
开发者ID:patricksadowski,项目名称:codeformatter,代码行数:28,代码来源:PrivateFieldNamingRule.cs

示例14: CreateAsync

        internal static async Task<ImmutableList<CodeFixEquivalenceGroup>> CreateAsync(CodeFixProvider codeFixProvider, IEnumerable<Diagnostic> allDiagnostics, Solution solution)
        {
            var fixAllProvider = codeFixProvider.GetFixAllProvider();

            var relevantDiagnostics = allDiagnostics.Where(diagnostic => codeFixProvider.FixableDiagnosticIds.Contains(diagnostic.Id)).ToImmutableArray();

            if (fixAllProvider == null)
            {
                return ImmutableList.Create<CodeFixEquivalenceGroup>();
            }

            List<CodeAction> actions = new List<CodeAction>();

            foreach (var diagnostic in relevantDiagnostics)
            {
                actions.AddRange(await GetFixesAsync(solution, codeFixProvider, diagnostic).ConfigureAwait(false));
            }

            List<CodeFixEquivalenceGroup> groups = new List<CodeFixEquivalenceGroup>();

            foreach (var item in actions.GroupBy(x => x.EquivalenceKey))
            {
                groups.Add(new CodeFixEquivalenceGroup(item.Key, solution, fixAllProvider, codeFixProvider, relevantDiagnostics));
            }

            return groups.ToImmutableList();
        }
开发者ID:robinsedlaczek,项目名称:StyleCopAnalyzers,代码行数:27,代码来源:CodeFixEquivalenceGroup.cs

示例15: FindDerivedInterfacesAsync

 public static Task<IEnumerable<INamedTypeSymbol>> FindDerivedInterfacesAsync(
     this INamedTypeSymbol type,
     Solution solution,
     CancellationToken cancellationToken)
 {
     return FindDerivedInterfacesAsync(type, solution, null, cancellationToken);
 }
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:7,代码来源:INamedTypeSymbolExtensions.cs


注:本文中的Microsoft.CodeAnalysis.Solution类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。