本文整理汇总了C#中ImmutableArray.Single方法的典型用法代码示例。如果您正苦于以下问题:C# ImmutableArray.Single方法的具体用法?C# ImmutableArray.Single怎么用?C# ImmutableArray.Single使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImmutableArray
的用法示例。
在下文中一共展示了ImmutableArray.Single方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetDebuggerBrowsableState
private static DebuggerBrowsableState GetDebuggerBrowsableState(ImmutableArray<SynthesizedAttributeData> attributes)
{
return (DebuggerBrowsableState)attributes.Single(a => a.AttributeClass.Name == "DebuggerBrowsableAttribute").ConstructorArguments.First().Value;
}
示例2: PublicAttributed
public void PublicAttributed( ImmutableArray<Type> types )
{
Assert.Single( types );
Assert.Equal( "DragonSpark.Testing.Parts.PublicClass", types.Single().FullName );
}
示例3: CheckCustomModifier
/// <summary>
/// True - assert that the list contains a single const modifier.
/// False - assert that the list is empty.
/// </summary>
private static void CheckCustomModifier(bool expectCustomModifier, ImmutableArray<CustomModifier> customModifiers)
{
if (expectCustomModifier)
{
Assert.Equal(ConstModOptType, customModifiers.Single().Modifier.ToTestDisplayString());
}
else
{
Assert.False(customModifiers.Any());
}
}
示例4: ApplyAsync
public async Task ApplyAsync(
Workspace workspace, Document fromDocument,
ImmutableArray<CodeActionOperation> operations,
string title, IProgressTracker progressTracker,
CancellationToken cancellationToken)
{
this.AssertIsForeground();
if (operations.IsDefaultOrEmpty)
{
return;
}
if (_renameService.ActiveSession != null)
{
workspace.Services.GetService<INotificationService>()?.SendNotification(
EditorFeaturesResources.Cannot_apply_operation_while_a_rename_session_is_active,
severity: NotificationSeverity.Error);
return;
}
#if DEBUG
var documentErrorLookup = new HashSet<DocumentId>();
foreach (var project in workspace.CurrentSolution.Projects)
{
foreach (var document in project.Documents)
{
// ConfigureAwait(true) so we come back to the same thread as
// we do all application on the UI thread.
if (!await document.HasAnyErrorsAsync(cancellationToken).ConfigureAwait(true))
{
documentErrorLookup.Add(document.Id);
}
}
}
#endif
var oldSolution = workspace.CurrentSolution;
// Determine if we're making a simple text edit to a single file or not.
// If we're not, then we need to make a linked global undo to wrap the
// application of these operations. This way we should be able to undo
// them all with one user action.
//
// The reason we don't always create a gobal undo is that a global undo
// forces all files to save. And that's rather a heavyweight and
// unexpected experience for users (for the common case where a single
// file got edited).
var singleChangedDocument = TryGetSingleChangedText(oldSolution, operations);
if (singleChangedDocument != null)
{
// ConfigureAwait(true) so we come back to the same thread as
// we do all application on the UI thread.
var text = await singleChangedDocument.GetTextAsync(cancellationToken).ConfigureAwait(true);
using (workspace.Services.GetService<ISourceTextUndoService>().RegisterUndoTransaction(text, title))
{
operations.Single().Apply(workspace, cancellationToken);
}
}
else
{
// More than just a single document changed. Make a global undo to run
// all the changes under.
using (var transaction = workspace.OpenGlobalUndoTransaction(title))
{
// ConfigureAwait(true) so we come back to the same thread as
// we do all application on the UI thread.
ProcessOperations(
workspace, operations, progressTracker,
cancellationToken);
// link current file in the global undo transaction
if (fromDocument != null)
{
transaction.AddDocument(fromDocument.Id);
}
transaction.Commit();
}
}
#if DEBUG
foreach (var project in workspace.CurrentSolution.Projects)
{
foreach (var document in project.Documents)
{
if (documentErrorLookup.Contains(document.Id))
{
document.VerifyNoErrorsAsync("CodeAction introduced error in error-free code", cancellationToken).Wait(cancellationToken);
}
}
}
#endif
var updatedSolution = operations.OfType<ApplyChangesOperation>().FirstOrDefault()?.ChangedSolution ?? oldSolution;
TryStartRenameSession(workspace, oldSolution, updatedSolution, cancellationToken);
}
示例5: TryGetSingleChangedText
private TextDocument TryGetSingleChangedText(
Solution oldSolution, ImmutableArray<CodeActionOperation> operationsList)
{
Debug.Assert(operationsList.Length > 0);
if (operationsList.Length > 1)
{
return null;
}
var applyOperation = operationsList.Single() as ApplyChangesOperation;
if (applyOperation == null)
{
return null;
}
var newSolution = applyOperation.ChangedSolution;
var changes = newSolution.GetChanges(oldSolution);
if (changes.GetAddedProjects().Any() ||
changes.GetRemovedProjects().Any())
{
return null;
}
var projectChanges = changes.GetProjectChanges().ToImmutableArray();
if (projectChanges.Length != 1)
{
return null;
}
var projectChange = projectChanges.Single();
if (projectChange.GetAddedAdditionalDocuments().Any() ||
projectChange.GetAddedAnalyzerReferences().Any() ||
projectChange.GetAddedDocuments().Any() ||
projectChange.GetAddedMetadataReferences().Any() ||
projectChange.GetAddedProjectReferences().Any() ||
projectChange.GetRemovedAdditionalDocuments().Any() ||
projectChange.GetRemovedAnalyzerReferences().Any() ||
projectChange.GetRemovedDocuments().Any() ||
projectChange.GetRemovedMetadataReferences().Any() ||
projectChange.GetRemovedProjectReferences().Any())
{
return null;
}
var changedAdditionalDocuments = projectChange.GetChangedAdditionalDocuments().ToImmutableArray();
var changedDocuments = projectChange.GetChangedDocuments().ToImmutableArray();
if (changedAdditionalDocuments.Length + changedDocuments.Length != 1)
{
return null;
}
return changedDocuments.Length == 1
? oldSolution.GetDocument(changedDocuments[0])
: oldSolution.GetAdditionalDocument(changedAdditionalDocuments[0]);
}
示例6: CompletionChange
private CompletionChange(ImmutableArray<TextChange> textChanges, int? newPosition, bool includesCommitCharacter)
: this(textChanges.Single(), newPosition, includesCommitCharacter)
{
}