本文整理汇总了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;
}
示例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;
}
}
示例3: LoadInitialSemanticVersions
public void LoadInitialSemanticVersions(Solution solution)
{
foreach (var project in solution.Projects)
{
LoadInitialSemanticVersions(project);
}
}
示例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);
}
示例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;
}
示例6: TestListCategorizer
public TestListCategorizer(string pathToVsmdiFile, string pathToSolution)
{
_workspace = MSBuildWorkspace.Create();
_solution = _workspace.OpenSolutionAsync(pathToSolution).Result;
var vsmdiParser = new VsmdiParser();
_testlists = vsmdiParser.ReadFile(pathToVsmdiFile);
}
示例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;
}
}
}
示例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;
}
示例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;
}
示例10: SolutionAnalayzer
public SolutionAnalayzer(string solutionPath)
{
_workspace = MSBuildWorkspace.Create();
_workspace.WorkspaceFailed += _workspace_WorkspaceFailed;
_solution = _workspace.OpenSolutionAsync(solutionPath).Result;
_refsourceLinkProvider.Init();
}
示例11: DisplayReferencedSymbols
public override void DisplayReferencedSymbols(Solution solution, IEnumerable<ReferencedSymbol> referencedSymbols)
{
foreach (var presenter in _referencedSymbolsPresenters)
{
presenter.Value.DisplayResult(solution, referencedSymbols);
}
}
示例12: MemberTarget
public MemberTarget(SourceTextContainer textContainer, ISymbol memberIdentifier, Project project, Solution solution)
{
_textContainer = textContainer;
_memberIdentifier = memberIdentifier;
_project = project;
_solution = solution;
}
示例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;
}
示例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();
}
示例15: FindDerivedInterfacesAsync
public static Task<IEnumerable<INamedTypeSymbol>> FindDerivedInterfacesAsync(
this INamedTypeSymbol type,
Solution solution,
CancellationToken cancellationToken)
{
return FindDerivedInterfacesAsync(type, solution, null, cancellationToken);
}