Skip to content

Commit 57b39a9

Browse files
authored
Revert usage of bang bang annotation (#3691)
1 parent 3617a9f commit 57b39a9

File tree

95 files changed

+593
-364
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+593
-364
lines changed

.editorconfig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ dotnet_diagnostic.CA1834.severity = warning # not default, increased severity to
198198

199199
# IDE0190: Null check can be simplified
200200
# Keep this in sync with the related C# rule: csharp_style_prefer_parameter_null_checking
201-
dotnet_diagnostic.IDE0190.severity = warning # not default, increased severity to ensure it is applied
201+
dotnet_diagnostic.IDE0190.severity = silent # not default, disabled as feature is no longer supported
202202

203203
# CA1840: Use 'Environment.CurrentManagedThreadId'
204204
dotnet_diagnostic.CA1840.severity = warning # not default, increased severity to ensure it is applied
@@ -264,7 +264,7 @@ csharp_using_directive_placement = outside_namespace:warning
264264

265265
# IDE0190: Null check can be simplified
266266
# Keep this in sync with the related .NET rule: IDE0190
267-
csharp_style_prefer_parameter_null_checking = true # not default, increased severity to ensure it is applied
267+
csharp_style_prefer_parameter_null_checking = false # not default, disabled as no longer supported
268268

269269
#### .NET Formatting Rules ####
270270

src/AttachVS/Program.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@ namespace Microsoft.TestPlatform.AttachVS;
99

1010
internal class Program
1111
{
12-
static void Main(string[] args!!)
12+
static void Main(string[] args)
1313
{
14+
_ = args ?? throw new ArgumentNullException(nameof(args));
15+
1416
Trace.Listeners.Add(new ConsoleTraceListener());
1517

1618
int? pid = ParsePid(args, position: 0);

src/DataCollectors/Microsoft.TestPlatform.Extensions.EventLogCollector/EventLogDataCollector.cs

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,16 @@ internal EventLogDataCollector(IFileHelper fileHelper)
151151
[MemberNotNull(nameof(_events), nameof(_dataSink), nameof(_logger))]
152152
public override void Initialize(
153153
XmlElement? configurationElement,
154-
DataCollectionEvents events!!,
155-
DataCollectionSink dataSink!!,
156-
DataCollectionLogger logger!!,
157-
DataCollectionEnvironmentContext dataCollectionEnvironmentContext!!)
154+
DataCollectionEvents events,
155+
DataCollectionSink dataSink,
156+
DataCollectionLogger logger,
157+
DataCollectionEnvironmentContext dataCollectionEnvironmentContext)
158158
{
159+
ValidateArg.NotNull(events, nameof(events));
160+
ValidateArg.NotNull(dataSink, nameof(dataSink));
161+
ValidateArg.NotNull(logger, nameof(logger));
162+
ValidateArg.NotNull(dataCollectionEnvironmentContext, nameof(dataCollectionEnvironmentContext));
163+
159164
_events = events;
160165
_dataSink = dataSink;
161166
_logger = logger;
@@ -320,26 +325,29 @@ private static ISet<string> ParseCommaSeparatedList(string commaSeparatedList)
320325
return strings;
321326
}
322327

323-
private void OnSessionStart(object sender, SessionStartEventArgs e!!)
328+
private void OnSessionStart(object sender, SessionStartEventArgs e)
324329
{
330+
ValidateArg.NotNull(e, nameof(e));
325331
ValidateArg.NotNull(e.Context, "SessionStartEventArgs.Context");
326332

327333
EqtTrace.Verbose("EventLogDataCollector: SessionStart received");
328334

329335
StartCollectionForContext(e.Context);
330336
}
331337

332-
private void OnSessionEnd(object sender, SessionEndEventArgs e!!)
338+
private void OnSessionEnd(object sender, SessionEndEventArgs e)
333339
{
340+
ValidateArg.NotNull(e, nameof(e));
334341
ValidateArg.NotNull(e.Context, "SessionEndEventArgs.Context");
335342

336343
EqtTrace.Verbose("EventLogDataCollector: SessionEnd received");
337344

338345
WriteCollectedEventLogEntries(e.Context, true, TimeSpan.MaxValue, DateTime.UtcNow);
339346
}
340347

341-
private void OnTestCaseStart(object sender, TestCaseStartEventArgs e!!)
348+
private void OnTestCaseStart(object sender, TestCaseStartEventArgs e)
342349
{
350+
ValidateArg.NotNull(e, nameof(e));
343351
ValidateArg.NotNull(e.Context, "TestCaseStartEventArgs.Context");
344352

345353
if (!e.Context.HasTestCase)
@@ -353,8 +361,9 @@ private void OnTestCaseStart(object sender, TestCaseStartEventArgs e!!)
353361
StartCollectionForContext(e.Context);
354362
}
355363

356-
private void OnTestCaseEnd(object sender, TestCaseEndEventArgs e!!)
364+
private void OnTestCaseEnd(object sender, TestCaseEndEventArgs e)
357365
{
366+
ValidateArg.NotNull(e, nameof(e));
358367
TPDebug.Assert(e.Context != null, "Context is null");
359368
TPDebug.Assert(e.Context.HasTestCase, "Context is not for a test case");
360369

src/Microsoft.TestPlatform.AdapterUtilities/ManagedNameUtilities/ManagedNameHelper.Reflection.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,10 @@ public static void GetManagedName(MethodBase method, out string managedTypeName,
8080
/// More information about <paramref name="managedTypeName"/> and <paramref name="managedMethodName"/> can be found in
8181
/// <see href="https://github.com/microsoft/vstest-docs/blob/main/RFCs/0017-Managed-TestCase-Properties.md">the RFC</see>.
8282
/// </remarks>
83-
public static void GetManagedName(MethodBase method!!, out string managedTypeName, out string managedMethodName, out string[] hierarchyValues)
83+
public static void GetManagedName(MethodBase method, out string managedTypeName, out string managedMethodName, out string[] hierarchyValues)
8484
{
85+
_ = method ?? throw new ArgumentNullException(nameof(method));
86+
8587
if (!ReflectionHelpers.IsMethod(method))
8688
{
8789
// TODO: @Haplois, exception expects a message and not a param name.

src/Microsoft.TestPlatform.Client/Execution/TestRunRequest.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,8 +355,10 @@ public void Dispose()
355355
/// <summary>
356356
/// Invoked when test run is complete
357357
/// </summary>
358-
public void HandleTestRunComplete(TestRunCompleteEventArgs runCompleteArgs!!, TestRunChangedEventArgs lastChunkArgs, ICollection<AttachmentSet> runContextAttachments, ICollection<string> executorUris)
358+
public void HandleTestRunComplete(TestRunCompleteEventArgs runCompleteArgs, TestRunChangedEventArgs lastChunkArgs, ICollection<AttachmentSet> runContextAttachments, ICollection<string> executorUris)
359359
{
360+
ValidateArg.NotNull(runCompleteArgs, nameof(runCompleteArgs));
361+
360362
bool isAborted = runCompleteArgs.IsAborted;
361363
bool isCanceled = runCompleteArgs.IsCanceled;
362364

src/Microsoft.TestPlatform.Client/TestPlatform.cs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using System.IO;
88
using System.Linq;
99
using System.Reflection;
10+
using System.Xml;
1011

1112
using Microsoft.VisualStudio.TestPlatform.Client.Discovery;
1213
using Microsoft.VisualStudio.TestPlatform.Client.Execution;
@@ -80,10 +81,12 @@ protected internal TestPlatform(
8081
/// <inheritdoc/>
8182
public IDiscoveryRequest CreateDiscoveryRequest(
8283
IRequestData requestData,
83-
DiscoveryCriteria discoveryCriteria!!,
84+
DiscoveryCriteria discoveryCriteria,
8485
TestPlatformOptions options,
8586
Dictionary<string, SourceDetail> sourceToSourceDetailMap)
8687
{
88+
ValidateArg.NotNull(discoveryCriteria, nameof(discoveryCriteria));
89+
8790
PopulateExtensions(discoveryCriteria.RunSettings, discoveryCriteria.Sources);
8891

8992
// Initialize loggers.
@@ -99,10 +102,12 @@ public IDiscoveryRequest CreateDiscoveryRequest(
99102
/// <inheritdoc/>
100103
public ITestRunRequest CreateTestRunRequest(
101104
IRequestData requestData,
102-
TestRunCriteria testRunCriteria!!,
105+
TestRunCriteria testRunCriteria,
103106
TestPlatformOptions options,
104107
Dictionary<string, SourceDetail> sourceToSourceDetailMap)
105108
{
109+
ValidateArg.NotNull(testRunCriteria, nameof(testRunCriteria));
110+
106111
IEnumerable<string> sources = GetSources(testRunCriteria);
107112
PopulateExtensions(testRunCriteria.TestRunSettings, sources);
108113

@@ -119,10 +124,12 @@ public ITestRunRequest CreateTestRunRequest(
119124
/// <inheritdoc/>
120125
public bool StartTestSession(
121126
IRequestData requestData,
122-
StartTestSessionCriteria testSessionCriteria!!,
127+
StartTestSessionCriteria testSessionCriteria,
123128
ITestSessionEventsHandler eventsHandler,
124129
Dictionary<string, SourceDetail> sourceToSourceDetailMap)
125130
{
131+
ValidateArg.NotNull(testSessionCriteria, nameof(testSessionCriteria));
132+
126133
RunConfiguration runConfiguration = XmlRunSettingsUtilities.GetRunConfigurationNode(testSessionCriteria.RunSettings);
127134
TestAdapterLoadingStrategy strategy = runConfiguration.TestAdapterLoadingStrategy;
128135

@@ -359,7 +366,7 @@ private static IEnumerable<string> ExpandAdaptersWithExplicitStrategy(string pat
359366

360367
private static IEnumerable<string> ExpandAdaptersWithDefaultStrategy(string path, IFileHelper fileHelper)
361368
{
362-
// This is the legacy behavior, please do not modify this method unless you're sure of
369+
// This is the legacy behavior, please do not modify this method unless you're sure of
363370
// side effect when running tests with legacy adapters.
364371
if (!fileHelper.DirectoryExists(path))
365372
{

src/Microsoft.TestPlatform.Common/DataCollection/DataCollectionAttachmentManager.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,11 @@ internal ConcurrentDictionary<DataCollectionContext, ConcurrentDictionary<Uri, A
9898
get; private set;
9999
}
100100
/// <inheritdoc/>
101-
public void Initialize(SessionId id!!, string outputDirectory, IMessageSink messageSink!!)
101+
public void Initialize(SessionId id, string outputDirectory, IMessageSink messageSink)
102102
{
103+
ValidateArg.NotNull(id, nameof(id));
104+
ValidateArg.NotNull(messageSink, nameof(messageSink));
105+
103106
_messageSink = messageSink;
104107

105108
if (outputDirectory.IsNullOrEmpty())
@@ -159,8 +162,10 @@ public List<AttachmentSet> GetAttachments(DataCollectionContext dataCollectionCo
159162
}
160163

161164
/// <inheritdoc/>
162-
public void AddAttachment(FileTransferInformation fileTransferInfo!!, AsyncCompletedEventHandler sendFileCompletedCallback, Uri uri, string friendlyName)
165+
public void AddAttachment(FileTransferInformation fileTransferInfo, AsyncCompletedEventHandler sendFileCompletedCallback, Uri uri, string friendlyName)
163166
{
167+
ValidateArg.NotNull(fileTransferInfo, nameof(fileTransferInfo));
168+
164169
if (SessionOutputDirectory.IsNullOrEmpty())
165170
{
166171
EqtTrace.Error("DataCollectionAttachmentManager.AddAttachment: Initialize not invoked.");

src/Microsoft.TestPlatform.Common/DataCollection/DataCollectionManager.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,12 @@ public static DataCollectionManager Create(IMessageSink messageSink, IRequestDat
154154
}
155155

156156
/// <inheritdoc/>
157-
public IDictionary<string, string> InitializeDataCollectors(string settingsXml!!)
157+
public IDictionary<string, string> InitializeDataCollectors(string settingsXml)
158158
{
159+
ValidateArg.NotNull(settingsXml, nameof(settingsXml));
159160
if (settingsXml.IsNullOrEmpty())
160161
{
161-
EqtTrace.Info("DataCollectionManager.InitializeDataCollectors : Runsettings is null or empty.");
162+
EqtTrace.Info("DataCollectionManager.InitializeDataCollectors: Runsettings is null or empty.");
162163
}
163164

164165
var sessionId = new SessionId(Guid.NewGuid());
@@ -585,8 +586,9 @@ private void LogWarning(string warningMessage)
585586
/// know when all plugins have completed processing the event
586587
/// </summary>
587588
/// <param name="args">The context information for the event</param>
588-
private void SendEvent(DataCollectionEventArgs args!!)
589+
private void SendEvent(DataCollectionEventArgs args)
589590
{
591+
ValidateArg.NotNull(args, nameof(args));
590592
if (!_isDataCollectionEnabled)
591593
{
592594
EqtTrace.Error("DataCollectionManger:SendEvent: SendEvent called when no collection is enabled.");

src/Microsoft.TestPlatform.Common/DataCollection/DataCollectorConfig.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ internal class DataCollectorConfig : TestExtensionPluginInformation
2424
/// <param name="type">
2525
/// The type.
2626
/// </param>
27-
public DataCollectorConfig(Type type!!)
27+
public DataCollectorConfig(Type type)
2828
: base(type)
2929
{
30-
DataCollectorType = type;
30+
DataCollectorType = type ?? throw new ArgumentNullException(nameof(type));
3131
TypeUri = GetTypeUri(type);
3232
FriendlyName = GetFriendlyName(type);
3333
AttachmentsProcessorType = GetAttachmentsProcessors(type);

src/Microsoft.TestPlatform.Common/DataCollection/TestPlatformDataCollectionEvents.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,10 @@ internal TestPlatformDataCollectionEvents()
7777
/// <param name="e">
7878
/// Contains the event data
7979
/// </param>
80-
internal void RaiseEvent(DataCollectionEventArgs e!!)
80+
internal void RaiseEvent(DataCollectionEventArgs e)
8181
{
82+
ValidateArg.NotNull(e, nameof(e));
83+
8284
if (_eventArgsToEventInvokerMap.TryGetValue(e.GetType(), out var onEvent))
8385
{
8486
onEvent(e);

0 commit comments

Comments
 (0)