Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,17 @@ public struct FilePatternMatch : IEquatable<FilePatternMatch>
/// If the matcher searched for "src/Project/**/*.cs" and the pattern matcher found "src/Project/Interfaces/IFile.cs",
/// then <see cref="Stem" /> = "Interfaces/IFile.cs" and <see cref="Path" /> = "src/Project/Interfaces/IFile.cs".
/// </remarks>
public string? Stem { get; }
public string Stem { get; }

/// <summary>
/// Initializes new instance of <see cref="FilePatternMatch" />
/// </summary>
/// <param name="path">The path to the file matched, relative to the beginning of the matching search pattern.</param>
/// <param name="stem">The subpath to the file matched, relative to the first wildcard in the matching search pattern.</param>
public FilePatternMatch(string path, string? stem)
public FilePatternMatch(string path, string stem)
{
ArgumentNullException.ThrowIfNull(path);
ArgumentNullException.ThrowIfNull(stem);

Path = path;
Stem = stem;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Diagnostics.CodeAnalysis;

namespace Microsoft.Extensions.FileSystemGlobbing.Internal
{
/// <summary>
Expand All @@ -11,6 +13,7 @@ public struct PatternTestResult
{
public static readonly PatternTestResult Failed = new(isSuccessful: false, stem: null);

[MemberNotNullWhen(returnValue: true, nameof(Stem))]
public bool IsSuccessful { get; }
public string? Stem { get; }

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using Xunit;

namespace Microsoft.Extensions.FileSystemGlobbing.Tests
Expand All @@ -24,5 +25,17 @@ public void TestGetHashCode()
FilePatternMatch matchCase2 = new FilePatternMatch("sub/sub2/bar/baz/three.txt", "Sub2/bar/baz/thrEE.txt");
Assert.Equal(matchCase1.GetHashCode(), matchCase2.GetHashCode());
}

[Fact]
public void TestPathArgumentNullExceptions()
{
Assert.Throws<ArgumentNullException>(() => new FilePatternMatch(null, "sub2/bar/baz/three.txt"));
}

[Fact]
public void TestStemArgumentNullExceptions()
{
Assert.Throws<ArgumentNullException>(() => new FilePatternMatch("sub2/bar/baz/three.txt", null));
}
}
}
Loading