提交 23ea8a57 编写于 作者: J Jason Malinowski

Add Solution.WithAnalyzerConfigDocumentText

上级 5be42c59
......@@ -10,6 +10,7 @@ Microsoft.CodeAnalysis.Solution.AddAnalyzerConfigDocuments(System.Collections.Im
Microsoft.CodeAnalysis.Solution.ContainsAnalyzerConfigDocument(Microsoft.CodeAnalysis.DocumentId documentId) -> bool
Microsoft.CodeAnalysis.Solution.GetAnalyzerConfigDocument(Microsoft.CodeAnalysis.DocumentId documentId) -> Microsoft.CodeAnalysis.AnalyzerConfigDocument
Microsoft.CodeAnalysis.Solution.RemoveAnalyzerConfigDocument(Microsoft.CodeAnalysis.DocumentId documentId) -> Microsoft.CodeAnalysis.Solution
Microsoft.CodeAnalysis.Solution.WithAnalyzerConfigDocumentText(Microsoft.CodeAnalysis.DocumentId documentId, Microsoft.CodeAnalysis.Text.SourceText text, Microsoft.CodeAnalysis.PreservationMode mode = Microsoft.CodeAnalysis.PreservationMode.PreserveValue) -> Microsoft.CodeAnalysis.Solution
Microsoft.CodeAnalysis.Solution.WithAnalyzerConfigDocumentTextLoader(Microsoft.CodeAnalysis.DocumentId documentId, Microsoft.CodeAnalysis.TextLoader loader, Microsoft.CodeAnalysis.PreservationMode mode) -> Microsoft.CodeAnalysis.Solution
Microsoft.CodeAnalysis.Workspace.CheckAnalyzerConfigDocumentIsInCurrentSolution(Microsoft.CodeAnalysis.DocumentId documentId) -> void
Microsoft.CodeAnalysis.Workspace.CheckAnalyzerConfigDocumentIsNotInCurrentSolution(Microsoft.CodeAnalysis.DocumentId documentId) -> void
......
......@@ -48,6 +48,11 @@ public new AnalyzerConfigDocumentState UpdateText(TextLoader loader, Preservatio
return (AnalyzerConfigDocumentState)base.UpdateText(loader, mode);
}
public new AnalyzerConfigDocumentState UpdateText(SourceText text, PreservationMode mode)
{
return (AnalyzerConfigDocumentState)base.UpdateText(text, mode);
}
protected override TextDocumentState UpdateText(ValueSource<TextAndVersion> newTextSource, PreservationMode mode, bool incremental)
{
return new AnalyzerConfigDocumentState(
......
......@@ -1024,6 +1024,21 @@ public Solution WithAdditionalDocumentTextLoader(DocumentId documentId, TextLoad
return new Solution(newState);
}
/// <summary>
/// Creates a new solution instance with the analyzer config document specified updated to have the text
/// supplied by the text loader.
/// </summary>
public Solution WithAnalyzerConfigDocumentText(DocumentId documentId, SourceText text, PreservationMode mode = PreservationMode.PreserveValue)
{
var newState = _state.WithAnalyzerConfigDocumentText(documentId, text, mode);
if (newState == _state)
{
return this;
}
return new Solution(newState);
}
/// <summary>
/// Creates a new solution instance with the analyzer config document specified updated to have the text
/// supplied by the text loader.
......
......@@ -1380,6 +1380,33 @@ public SolutionState WithAdditionalDocumentText(DocumentId documentId, SourceTex
return newSolution;
}
/// <summary>
/// Creates a new solution instance with the document specified updated to have the text
/// specified.
/// </summary>
public SolutionState WithAnalyzerConfigDocumentText(DocumentId documentId, SourceText text, PreservationMode mode = PreservationMode.PreserveValue)
{
if (documentId == null)
{
throw new ArgumentNullException(nameof(documentId));
}
if (text == null)
{
throw new ArgumentNullException(nameof(text));
}
CheckContainsAnalyzerConfigDocument(documentId);
var oldDocument = this.GetAnalyzerConfigDocumentState(documentId);
if (oldDocument.TryGetText(out var oldText) && text == oldText)
{
return this;
}
return this.WithAnalyzerConfigDocumentState(oldDocument.UpdateText(text, mode), textChanged: true);
}
/// <summary>
/// Creates a new solution instance with the document specified updated to have the text
/// and version specified.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册