Skip to content

Commit

Permalink
Improve nullability tags across the repo (#857)
Browse files Browse the repository at this point in the history
* Turn on nullability for CLI.Tests

* Clean #nullable

* Run code cleanup

* Revert XHarnessCommandHelp
  • Loading branch information
premun authored Apr 8, 2022
1 parent ec13ccb commit 7501abf
Show file tree
Hide file tree
Showing 48 changed files with 159 additions and 207 deletions.
2 changes: 1 addition & 1 deletion src/Microsoft.DotNet.XHarness.Android/AdbRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -855,7 +855,7 @@ private T Retry<T>(Func<T> action, Func<T, bool> needsRetry, TimeSpan retryInter
int attempt = 0;

T result;
while(true)
while (true)
{
result = action();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ private ExitCode ParseResult(
try
{
exitCode = exitCodeDetector.DetectExitCode(appBundleInfo, log);

if (exitCode.HasValue)
{
_logger.LogDebug($"Detected exit code {exitCode.Value} from {log.FullPath}");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Microsoft.DotNet.XHarness.CLI.CommandArguments.Android;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

namespace Microsoft.DotNet.XHarness.CLI.CommandArguments;

internal class TypeFromAssemblyArgument<T>: Argument<IList<(string path, string? type)>>
internal class TypeFromAssemblyArgument<T> : Argument<IList<(string path, string? type)>>
where T : class
{
private readonly bool _repeatable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Runtime.InteropServices;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.DotNet.XHarness.CLI.CommandArguments.Wasm;
using Microsoft.DotNet.XHarness.Common;
using Microsoft.DotNet.XHarness.Common.CLI;
using Microsoft.DotNet.XHarness.Common.Execution;
using Microsoft.DotNet.XHarness.Common.Logging;
using Microsoft.Extensions.Logging;
using System.Threading;
using Microsoft.DotNet.XHarness.Common;
using Microsoft.Extensions.DependencyInjection;
using System.Linq;
using Microsoft.Extensions.Logging;

namespace Microsoft.DotNet.XHarness.CLI.Commands.Wasm;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
using System.Text.Json;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using Microsoft.DotNet.XHarness.Common;
using Microsoft.Extensions.Logging;

#nullable enable
namespace Microsoft.DotNet.XHarness.CLI.Commands.Wasm;
Expand Down
1 change: 0 additions & 1 deletion src/Microsoft.DotNet.XHarness.CLI/Commands/WebServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Net.WebSockets;
using System.Runtime.Loader;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using System.Threading.Tasks;
using Microsoft.DotNet.XHarness.Common.Logging;

#nullable enable
namespace Microsoft.DotNet.XHarness.Common.Execution;

public interface IMacOSProcessManager : IProcessManager
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
using System.Threading.Tasks;
using Microsoft.DotNet.XHarness.Common.Logging;

#nullable enable
namespace Microsoft.DotNet.XHarness.Common.Execution;

public class ProcessExecutionResult
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
using Microsoft.DotNet.XHarness.Common.CLI;
using Microsoft.DotNet.XHarness.Common.Logging;

#nullable enable
namespace Microsoft.DotNet.XHarness.Common.Execution;

public class MacOSProcessManager : UnixProcessManager, IMacOSProcessManager
Expand Down
10 changes: 5 additions & 5 deletions src/Microsoft.DotNet.XHarness.Common/Execution/ProcessManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -300,11 +300,11 @@ protected static async Task<ProcessExecutionResult> RunAsyncInternal(
}
catch
{
// Process.HasExited can sometimes throw exceptions, so
// just ignore those and to be safe treat it as the
// process didn't exit (the safe option being to not leave
// processes behind).
}
// Process.HasExited can sometimes throw exceptions, so
// just ignore those and to be safe treat it as the
// process didn't exit (the safe option being to not leave
// processes behind).
}
if (!hasExited)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using System.Collections.Generic;
using System.IO;

#nullable enable
namespace Microsoft.DotNet.XHarness.Common.Logging;

public abstract partial class Log
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

#nullable enable
namespace Microsoft.DotNet.XHarness.Common.Logging;

public interface IFileBackedLog : IReadableLog
Expand Down
1 change: 0 additions & 1 deletion src/Microsoft.DotNet.XHarness.Common/Logging/Log.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using System;
using System.Text;

#nullable enable
namespace Microsoft.DotNet.XHarness.Common.Logging;

public abstract partial class Log : ILog
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

using System.IO;

#nullable enable
namespace Microsoft.DotNet.XHarness.Common.Logging;

public interface IReadableLog : ILog
Expand Down
1 change: 0 additions & 1 deletion src/Microsoft.DotNet.XHarness.Common/Logging/ScanLog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

using System;

#nullable enable
namespace Microsoft.DotNet.XHarness.Common.Logging;

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using System;
using System.Collections.Generic;

#nullable enable
namespace Microsoft.DotNet.XHarness.Common.Utilities;

public class DisposableList<T> : List<T>, IDisposable where T : IDisposable
Expand Down
2 changes: 0 additions & 2 deletions src/Microsoft.DotNet.XHarness.Common/Utilities/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

#nullable enable

using System;
using System.Threading.Tasks;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Threading.Tasks;

#nullable enable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
// See the LICENSE file in the project root for more information.

using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;

#nullable enable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;

#nullable enable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
#nullable enable
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.


using System;
using System.IO;
using System.Threading.Tasks;
using Microsoft.DotNet.XHarness.TestRunners.Common;

#nullable enable
namespace Microsoft.DotNet.XHarness.TestRunners.Xunit;

public abstract class AndroidApplicationEntryPoint : AndroidApplicationEntryPointBase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

#nullable enable
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using Xunit.Abstractions;

#nullable enable
namespace Microsoft.DotNet.XHarness.TestRunners.Xunit;

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,19 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

#nullable enable

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Xml.Linq;
using Microsoft.DotNet.XHarness.Common;
using Microsoft.DotNet.XHarness.TestRunners.Common;
using Xunit;
using Xunit.Abstractions;

#nullable enable
namespace Microsoft.DotNet.XHarness.TestRunners.Xunit;

internal class ThreadlessXunitTestRunner : XunitTestRunnerBase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

#nullable enable

using System;
using System.Collections.Generic;
using System.Reflection;
using System.Threading.Tasks;
using Microsoft.DotNet.XHarness.TestRunners.Common;
using Xunit;

#nullable enable
namespace Microsoft.DotNet.XHarness.TestRunners.Xunit;

public abstract class WasmApplicationEntryPoint : WasmApplicationEntryPointBase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

#nullable enable
using System;
using System.IO;
using System.Linq;
using System.Text;
using Microsoft.DotNet.XHarness.TestRunners.Common;
using Xunit.Abstractions;

#nullable enable
namespace Microsoft.DotNet.XHarness.TestRunners.Xunit;

internal class XUnitFilter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

#nullable enable
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.DotNet.XHarness.TestRunners.Common;
using Xunit.Abstractions;

#nullable enable
namespace Microsoft.DotNet.XHarness.TestRunners.Xunit;

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.DotNet.XHarness.TestRunners.Common;

#nullable enable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;
using System.Threading.Tasks;
using Microsoft.DotNet.XHarness.TestRunners.Common;

#nullable enable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ public void Open(string device, ITunnelListener simpleListener, TimeSpan timeout
_tcpTunnelExecutionTask = _processManager.ExecuteCommandAsync(tcpArgs, tunnelbackLog, timeout, cancellationToken: _cancellationToken.Token);
_tcpTunnelExecutionTask.ContinueWith(delegate (Task<ProcessExecutionResult> task)
{
// if the task completes, means that we had issues with the creation of the tunnel and the process
// exited, if that is the case, we do not want to make the app wait, therefore, set the hole to false
// which will throw an exception from the listener.
simpleListener.TunnelHoleThrough.TrySetResult(task.Result.Succeeded);
// if the task completes, means that we had issues with the creation of the tunnel and the process
// exited, if that is the case, we do not want to make the app wait, therefore, set the hole to false
// which will throw an exception from the listener.
simpleListener.TunnelHoleThrough.TrySetResult(task.Result.Succeeded);
});
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/Microsoft.DotNet.XHarness.iOS.Shared/TestReporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ public TestReporter(

CallbackLog = new CallbackLog(line =>
{
// MT1111: Application launched successfully, but it's not possible to wait for the app to exit as
// requested because it's not possible to detect app termination when launching using gdbserver
_waitedForExit &= line?.Contains("MT1111: ") != true;
// MT1111: Application launched successfully, but it's not possible to wait for the app to exit as
// requested because it's not possible to detect app termination when launching using gdbserver
_waitedForExit &= line?.Contains("MT1111: ") != true;
if (line?.Contains("error MT1007") == true)
{
_launchFailure = true;
Expand Down Expand Up @@ -301,7 +301,7 @@ public void LaunchCallback(Task<bool> launchResult)
_mainLog.WriteLine("Test execution started");
return;
}

_cancellationTokenSource.Cancel();
_timedout = true;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1231,24 +1231,24 @@ public static void ResolveAllPaths(this XmlDocument csproj, string project_path,
if (input[0] == '/')
{
return input; // This is already a full path.
}
}
input = input.Replace('\\', '/'); // make unix-style
if (rootDirectory != null)
if (rootDirectory != null)
{
input = input.Replace("$(RootTestsDirectory)", rootDirectory);
}
// Don't process anything that starts with a variable, it's either a full path already, or the variable will be updated according to the new location
if (input.StartsWith("$(", StringComparison.Ordinal))
// Don't process anything that starts with a variable, it's either a full path already, or the variable will be updated according to the new location
if (input.StartsWith("$(", StringComparison.Ordinal))
{
return input;
}
input = Path.GetFullPath(Path.Combine(dir, input));
input = input.Replace('/', '\\'); // make windows-style again
return input;
return input;
};

foreach (var key in nodes_with_paths)
Expand Down
Loading

0 comments on commit 7501abf

Please sign in to comment.