Skip to content

Commit

Permalink
Corrected warnings after toggling the analysislevel
Browse files Browse the repository at this point in the history
  • Loading branch information
heqianwang committed Feb 6, 2024
1 parent 379f593 commit 5d9077e
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ public async Task Distributed_Tracing_On_Mongo_Commands_Works()
var activities = recorder.RecordedActivities.ToArray();
Assert.NotEmpty(activities);
var activity = Assert.Single(activities, x => x.DisplayName == "things.insert");
this.Logger.LogInformation("{Count}", activities.Length);

Assert.Equal("MongoDB.Driver.Core.Events.Command", activity.OperationName);
Assert.Equal(ActivityStatusCode.Ok, activity.Status);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ public async Task EventSubscribers_Are_Executed_In_The_Right_Order()
{
_ = await this.Services.GetRequiredService<IMongoCollection<DummyDocument>>().FindAsync(Builders<DummyDocument>.Filter.Empty);
var actualOutput = this.Services.GetRequiredService<StringBuilder>().ToString();
this.Logger.LogInformation("Event subscribers call hierarchy: \r\n{Ouput}", actualOutput);

const string expectedOutput = @"
CommandTracingEventSubscriber.CommandStartedEvent(find)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,11 @@ async Task AcquireAction(string lockId)
}

var lockId = i % 2 == 0 ? lockId1 : lockId2;
#pragma warning disable CA2008
#pragma warning disable xUnit1031 // Deliberately trying to create deadlock for unit test
tasks[i] = Task.Factory.StartNew(() => AcquireAction(lockId).GetAwaiter().GetResult(), TaskCreationOptions.LongRunning);
#pragma warning restore xUnit1031
#pragma warning restore CA2008
}

await Task.WhenAll(tasks);
Expand Down Expand Up @@ -107,10 +109,11 @@ async Task AcquireAction(string lockId)
Interlocked.Increment(ref ocexCount);
}
}

#pragma warning disable CA2008
#pragma warning disable xUnit1031 // Deliberately trying to create deadlock for unit test
tasks[i] = Task.Factory.StartNew(() => AcquireAction("foo").GetAwaiter().GetResult(), TaskCreationOptions.LongRunning);
#pragma warning restore xUnit1031
#pragma warning restore CA2008
}

await Task.WhenAll(tasks);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ IBsonSerializer Create(SerializerKey x)

public static bool IsSensitiveType(Type type) => SensitiveTypesCache.HasSensitiveProperty(type);

private readonly struct SerializerKey
private readonly struct SerializerKey : IEquatable<SerializerKey>
{
public SerializerKey(Type valueType, SensitivityScope sensitivityScope)
{
Expand All @@ -61,7 +61,7 @@ public override bool Equals(object? obj)
return obj is SerializerKey other && this.Equals(other);
}

private bool Equals(SerializerKey other)
public bool Equals(SerializerKey other)
{
return this.ValueType == other.ValueType && this.SensitivityScope == other.SensitivityScope;
}
Expand Down

0 comments on commit 5d9077e

Please sign in to comment.