Skip to content

Commit

Permalink
use some more guards (#3840)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonCropp authored Sep 15, 2024
1 parent d2c4636 commit 4c5ad69
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,7 @@ class AssemblyResolver :
/// </remarks>
public AssemblyResolver(IList<string> directories)
{
if (directories == null || directories.Count == 0)
{
throw new ArgumentNullException(nameof(directories));
}
Guard.NotNullOrEmpty(directories);

_searchDirectories = [.. directories];
_directoryList = new Queue<RecursiveDirectoryPath>();
Expand Down
2 changes: 1 addition & 1 deletion src/TestFramework/TestFramework.Extensions/PrivateType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ public object GetStaticProperty(string name, BindingFlags bindingFlags, Type[]?
/// <param name="args">Arguments to pass to the member to invoke.</param>
public void SetStaticProperty(string name, BindingFlags bindingFlags, object value, Type[]? parameterTypes, object?[]? args)
{
_ = name ?? throw new ArgumentNullException(nameof(name));
Guard.NotNull(name);

if (parameterTypes != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
using System.Text;
using System.Xml.Linq;

using Polyfills;

namespace Microsoft.Testing.TestInfrastructure;

public class VSSolution : Folder
Expand Down Expand Up @@ -42,15 +44,8 @@ public class VSSolution : Folder
public VSSolution(string? solutionFolder, string? solutionName)
: base(solutionFolder)
{
if (string.IsNullOrEmpty(solutionFolder))
{
throw new ArgumentNullException(nameof(solutionFolder));
}

if (string.IsNullOrEmpty(solutionName))
{
throw new ArgumentNullException(nameof(solutionName));
}
Guard.NotNullOrWhiteSpace(solutionFolder);
Guard.NotNullOrWhiteSpace(solutionName);

_solutionFileName = $"{solutionName}.sln";
SolutionFile = Path.Combine(FolderPath, _solutionFileName);
Expand Down Expand Up @@ -93,20 +88,9 @@ public class CSharpProject : Project
public CSharpProject(string solutionFolder, string projectName, params string[]? tfms)
: base(Path.Combine(solutionFolder, projectName))
{
if (string.IsNullOrEmpty(solutionFolder))
{
throw new ArgumentNullException(nameof(solutionFolder));
}

if (string.IsNullOrEmpty(projectName))
{
throw new ArgumentNullException(nameof(projectName));
}

if (tfms is null || tfms.Length == 0)
{
throw new ArgumentException("Invalid tfm", nameof(tfms));
}
Guard.NotNullOrWhiteSpace(solutionFolder);
Guard.NotNullOrWhiteSpace(projectName);
Guard.NotEmpty(tfms);

_projectFileName = $"{projectName}.csproj";
ProjectFile = Path.Combine(FolderPath, _projectFileName);
Expand Down

0 comments on commit 4c5ad69

Please sign in to comment.