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
1 change: 0 additions & 1 deletion src/SPDXLicenseMatcher/FastLicenseMatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ public class FastLicenseMatcher : ILicenseMatcher
private static readonly Regex BEGIN_OPTIONAL_COMMENT_PATTERN = new Regex("^\\s*<<beginOptional>>\\s*" + START_COMMENT_CHAR_PATTERN, RegexOptions.Compiled);
#pragma warning restore IDE1006


private readonly IImmutableDictionary<string, ParseInstruction> _templateInstructions;

public FastLicenseMatcher(IDictionary<string, ILicense> licenses)
Expand Down
24 changes: 24 additions & 0 deletions tests/SPDXLicenseMatcher.Test/LicenseMatcherTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,23 @@ public static IEnumerable<Func<string>> GetCases()
}
}

public static class RealWorldLicenses
{
private const string PREFIX = "SPDXLicenseMatcher.Test.RealLicenses.";
private static readonly int s_prefixLength = PREFIX.Length;
public static IEnumerable<Func<Case>> GetCases()
{
var executingAssembly = System.Reflection.Assembly.GetExecutingAssembly();
foreach (string name in executingAssembly.GetManifestResourceNames().Where(n => n.StartsWith(PREFIX)).Where(n => n.EndsWith("txt")))
{
string fileName = name.Substring(s_prefixLength);
string expectedIdentifier = fileName.Split("__")[0];
using var reader = new StreamReader(executingAssembly.GetManifestResourceStream(name)!);
yield return () => new Case(expectedIdentifier, reader.ReadToEnd());
}
}
}

#pragma warning disable S125 // Sections of code should not be commented out
/*
[Test]
Expand Down Expand Up @@ -78,5 +95,12 @@ public async Task Fast_License_Matcher_Should_Not_Pick_A_License(string licenseT
{
await Assert.That(FastlicenseMatcher.Match(licenseText)).IsEmpty();
}

[Test]
[MethodDataSource(typeof(RealWorldLicenses), nameof(RealWorldLicenses.GetCases))]
public async Task Fast_License_Matcher_Should_Mattch_Real_World_Licenses(Case @case)
{
await Assert.That(FastlicenseMatcher.Match(@case.Content)).Contains(@case.Identifier);
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
MIT License

Copyright (c) 2025 John Doe

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
4 changes: 1 addition & 3 deletions tests/SPDXLicenseMatcher.Test/SPDXLicenseMatcher.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@

<ItemGroup>
<EmbeddedResource Include="SPDXLicenses\*" />
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="NonSpdxTestLicenses\*" />
<EmbeddedResource Include="RealLicenses\*" />
</ItemGroup>
</Project>
Loading