Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
  • Loading branch information
tmat committed May 23, 2024
1 parent 4c93fab commit fb279a5
Show file tree
Hide file tree
Showing 22 changed files with 625 additions and 160 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ private static bool CanBeOptional(ParameterSymbol parameter, bool isMethodGroupC

private static int? CheckForDuplicateNamedArgument(AnalyzedArguments arguments)
{
if (arguments.Names.IsEmpty())
if (arguments.Names.IsEmpty)
{
// No checks if there are no named arguments
return null;
Expand Down
8 changes: 4 additions & 4 deletions src/Compilers/CSharp/Portable/Compiler/MethodCompiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -281,10 +281,10 @@ private static MethodSymbol GetEntryPoint(CSharpCompilation compilation, PEModul
Debug.Assert(lazyVariableSlotAllocator is null);
Debug.Assert(stateMachineTypeOpt is null);
Debug.Assert(codeCoverageSpans.IsEmpty);
Debug.Assert(lambdaDebugInfoBuilder.IsEmpty());
Debug.Assert(lambdaRuntimeRudeEditsBuilder.IsEmpty());
Debug.Assert(closureDebugInfoBuilder.IsEmpty());
Debug.Assert(stateMachineStateDebugInfoBuilder.IsEmpty());
Debug.Assert(lambdaDebugInfoBuilder.IsEmpty);
Debug.Assert(lambdaRuntimeRudeEditsBuilder.IsEmpty);
Debug.Assert(closureDebugInfoBuilder.IsEmpty);
Debug.Assert(stateMachineStateDebugInfoBuilder.IsEmpty);

lambdaDebugInfoBuilder.Free();
lambdaRuntimeRudeEditsBuilder.Free();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public void Close(bool isMethodBody)

if (isMethodBody)
{
Debug.Assert(_lazyPreviousContextVariables?.IsEmpty() != false);
Debug.Assert(_lazyPreviousContextVariables?.IsEmpty != false);
_lazyPreviousContextVariables?.Free();
_lazyPreviousContextVariables = null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ protected StateMachineRewriter(
Debug.Assert(compilationState != null);
Debug.Assert(diagnostics != null);
Debug.Assert(diagnostics.DiagnosticBag != null);
Debug.Assert(stateMachineStateDebugInfoBuilder.IsEmpty());
Debug.Assert(stateMachineStateDebugInfoBuilder.IsEmpty);

this.body = body;
this.method = method;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ private ImmutableArray<SwitchBucket> GenerateSwitchBuckets(int startLabelIndex,
// merge top bucket on stack into newBucket, and pop bucket from stack
// End While

while (!switchBucketsStack.IsEmpty())
while (!switchBucketsStack.IsEmpty)
{
// get the bucket at top of the stack
SwitchBucket prevBucket = switchBucketsStack.Peek();
Expand All @@ -217,7 +217,7 @@ private ImmutableArray<SwitchBucket> GenerateSwitchBuckets(int startLabelIndex,
curStartLabelIndex++;
}

Debug.Assert(!switchBucketsStack.IsEmpty());
Debug.Assert(switchBucketsStack is not []);

// crumble leaf buckets into degenerate buckets where possible
var crumbled = ArrayBuilder<SwitchBucket>.GetInstance();
Expand Down
8 changes: 7 additions & 1 deletion src/Dependencies/PooledObjects/ArrayBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace Microsoft.CodeAnalysis.PooledObjects
{
[DebuggerDisplay("Count = {Count,nq}")]
[DebuggerTypeProxy(typeof(ArrayBuilder<>.DebuggerProxy))]
internal sealed partial class ArrayBuilder<T> : IReadOnlyCollection<T>, IReadOnlyList<T>
internal sealed partial class ArrayBuilder<T> : IReadOnlyCollection<T>, IReadOnlyList<T>, ICollection<T>
{
/// <summary>
/// See <see cref="Free()"/> for an explanation of this constant value.
Expand Down Expand Up @@ -139,6 +139,12 @@ public T this[int index]
}
}

public bool IsReadOnly
=> false;

public bool IsEmpty
=> Count == 0;

/// <summary>
/// Write <paramref name="value"/> to slot <paramref name="index"/>.
/// Fills in unallocated slots preceding the <paramref name="index"/>, if any.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ public async ValueTask<ManagedHotReloadUpdates> GetUpdatesAsync(CancellationToke

UpdateApplyChangesDiagnostics(diagnosticData);

var diagnostics = await EmitSolutionUpdateResults.GetHotReloadDiagnosticsAsync(solution, diagnosticData, rudeEdits, syntaxError, moduleUpdates.Status, cancellationToken).ConfigureAwait(false);
var diagnostics = await EmitSolutionUpdateResults.GetAllDiagnosticsAsync(solution, diagnosticData, rudeEdits, syntaxError, moduleUpdates.Status, cancellationToken).ConfigureAwait(false);
return new ManagedHotReloadUpdates(moduleUpdates.Updates.FromContract(), diagnostics.FromContract());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,11 @@ public async Task Test(bool commitChanges)

var localService = localWorkspace.GetService<EditAndContinueLanguageService>();

var projectId = ProjectId.CreateNewId();
var documentId = DocumentId.CreateNewId(projectId);

DocumentId documentId;
await localWorkspace.ChangeSolutionAsync(localWorkspace.CurrentSolution
.AddProject(projectId, "proj", "proj", LanguageNames.CSharp)
.AddTestProject("proj", out var projectId).Solution
.AddMetadataReferences(projectId, TargetFrameworkUtil.GetReferences(TargetFramework.Mscorlib40))
.AddDocument(documentId, "test.cs", SourceText.From("class C { }", Encoding.UTF8), filePath: "test.cs"));
.AddDocument(documentId = DocumentId.CreateNewId(projectId), "test.cs", SourceText.From("class C { }", Encoding.UTF8), filePath: "test.cs"));

var solution = localWorkspace.CurrentSolution;
var project = solution.GetRequiredProject(projectId);
Expand Down Expand Up @@ -139,12 +137,13 @@ await localWorkspace.ChangeSolutionAsync(localWorkspace.CurrentSolution
AssertEx.Equal(
[
$"Error ENC1001: test.cs(0, 1, 0, 2): {string.Format(FeaturesResources.ErrorReadingFile, "doc", "error 1")}",
$"Error ENC1001: {string.Format(FeaturesResources.ErrorReadingFile, "proj", "error 2")}"
$"Error ENC1001: proj.csproj(0, 0, 0, 0): {string.Format(FeaturesResources.ErrorReadingFile, "proj", "error 2")}"
], sessionState.ApplyChangesDiagnostics.Select(Inspect));

AssertEx.Equal(
[
$"Error ENC1001: test.cs(0, 1, 0, 2): {string.Format(FeaturesResources.ErrorReadingFile, "doc", "error 1")}",
$"Error ENC1001: proj.csproj(0, 0, 0, 0): {string.Format(FeaturesResources.ErrorReadingFile, "proj", "error 2")}",
$"Error ENC1001: test.cs(0, 1, 0, 2): {string.Format(FeaturesResources.ErrorReadingFile, "doc", "syntax error 3")}",
$"RestartRequired ENC0033: test.cs(0, 2, 0, 3): {string.Format(FeaturesResources.Deleting_0_requires_restarting_the_application, "x")}"
], updates.Diagnostics.Select(Inspect));
Expand Down
Loading

0 comments on commit fb279a5

Please sign in to comment.