forked from tomchavakis/nuget-license
-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add basic support for license expressions
- Loading branch information
Showing
32 changed files
with
1,253 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -87,7 +87,7 @@ jobs: | |
strategy: | ||
matrix: | ||
targetFramework: [net6.0, net7.0, net8.0] | ||
project: [App, Tests] | ||
project: [App, Tests, ProjectWithReferenceContainingLicenseExpression] | ||
|
||
include: | ||
- targetFramework: net6.0 | ||
|
@@ -110,7 +110,7 @@ jobs: | |
dotnet-version: ${{ matrix.dotnetVersion }} | ||
|
||
- name: restore | ||
run: dotnet restore -p:TargetFramework=${{ matrix.targetFramework }} | ||
run: dotnet restore NuGetUtility.sln | ||
|
||
- name: build | ||
run: dotnet publish ./src/NuGetLicenseCore/NuGetLicenseCore.csproj --configuration Release -o ./release -f ${{ matrix.targetFramework }} --no-restore | ||
|
@@ -131,7 +131,7 @@ jobs: | |
runs-on: windows-latest | ||
strategy: | ||
matrix: | ||
project: [App, Tests] | ||
project: [App, Tests, ProjectWithReferenceContainingLicenseExpression] | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
@@ -195,7 +195,7 @@ jobs: | |
dotnet-version: ${{ matrix.dotnetVersion }} | ||
|
||
- name: restore | ||
run: dotnet restore -p:TargetFramework=${{ matrix.targetFramework }} | ||
run: dotnet restore NuGetUtility.sln | ||
|
||
- uses: paulhatch/[email protected] | ||
id: version | ||
|
1 change: 1 addition & 0 deletions
1
...hub/workflows/assets/ProjectWithReferenceContainingLicenseExpression/allowedLicenses.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
["MIT","Apache-2.0","MS-EULA"] |
1 change: 1 addition & 0 deletions
1
.github/workflows/assets/ProjectWithReferenceContainingLicenseExpression/ignorePackages.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
["NETStandard.Library"] |
2 changes: 2 additions & 0 deletions
2
...s/assets/ProjectWithReferenceContainingLicenseExpression/overwritePackageInformation.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[ | ||
] |
1 change: 1 addition & 0 deletions
1
...hub/workflows/assets/ProjectWithReferenceContainingLicenseExpression/projectsToCheck.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
["./integration/ProjectWithReferenceContainingLicenseExpression/ProjectWithReferenceContainingLicenseExpression.csproj"] |
2 changes: 2 additions & 0 deletions
2
...workflows/assets/ProjectWithReferenceContainingLicenseExpression/urlToLicenseMapping.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
...ferenceContainingLicenseExpression/ProjectWithReferenceContainingLicenseExpression.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netstandard2.1</TargetFramework> | ||
<Configurations>Debug;Release;TestWindows</Configurations> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="CsvHelper" Version="31.0.2" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// Licensed to the projects contributors. | ||
// The license conditions are provided in the LICENSE file located in the project root | ||
|
||
using System; | ||
|
||
namespace Tethys.SPDX.ExpressionParser | ||
{ | ||
/// <summary> | ||
/// Represents an SPDX expression. | ||
/// </summary> | ||
public class SpdxAndExpression : SpdxExpression | ||
{ | ||
//// Annex D SPDX license expressions | ||
//// compound-expression "AND" compound-expression | ||
|
||
#region PUBLIC PROPERTIES | ||
/// <summary> | ||
/// Gets the left side of the expression. | ||
/// </summary> | ||
public SpdxExpression Left { get; } | ||
|
||
/// <summary> | ||
/// Gets the right side of the expression. | ||
/// </summary> | ||
public SpdxExpression Right { get; } | ||
#endregion // PUBLIC PROPERTIES | ||
|
||
//// --------------------------------------------------------------------- | ||
|
||
#region CONSTRUCTION | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="SpdxAndExpression"/> class. | ||
/// </summary> | ||
/// <param name="left">The left.</param> | ||
/// <param name="right">The right.</param> | ||
public SpdxAndExpression(SpdxExpression? left, SpdxExpression? right) | ||
{ | ||
Left = left ?? throw new ArgumentNullException(nameof(left)); | ||
Right = right ?? throw new ArgumentNullException(nameof(right)); | ||
} // SpdxAndExpression() | ||
#endregion // CONSTRUCTION | ||
|
||
//// --------------------------------------------------------------------- | ||
|
||
#region PUBLIC METHODS | ||
/// <inheritdoc /> | ||
public override string ToString() | ||
{ | ||
return $"{Left.ToString()} AND {Right.ToString()}"; | ||
} // ToString() | ||
#endregion // PUBLIC METHODS | ||
} // SpdxAndExpression | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Licensed to the projects contributors. | ||
// The license conditions are provided in the LICENSE file located in the project root | ||
|
||
namespace Tethys.SPDX.ExpressionParser | ||
{ | ||
/************************************************************************* | ||
* SPDX Expressions | ||
* ---------------- | ||
* idstring = 1*(ALPHA / DIGIT / "-" / "." ) | ||
* | ||
* license-id = <short form license identifier in Annex A.1> | ||
* | ||
* license-exception-id = <short form license exception identifier in Annex A.2> | ||
* | ||
* license-ref = ["DocumentRef-"(idstring)":"]"LicenseRef-"(idstring) | ||
* | ||
* simple-expression = license-id / license-id"+" / license-ref | ||
* | ||
* compound-expression = (simple-expression / | ||
* simple-expression "WITH" license-exception-id / | ||
* compound-expression "AND" compound-expression / | ||
* compound-expression "OR" compound-expression / | ||
* "(" compound-expression ")" ) | ||
* | ||
* license-expression = (simple-expression / compound-expression) | ||
* | ||
************************************************************************/ | ||
|
||
/// <summary> | ||
/// Represents an SPDX expression. | ||
/// </summary> | ||
public abstract class SpdxExpression | ||
{ | ||
/// <summary> | ||
/// Converts an <see cref="SpdxExpression"/> to a string. | ||
/// </summary> | ||
/// <returns> | ||
/// A <see cref="string" /> that represents this instance. | ||
/// </returns> | ||
public new abstract string ToString(); | ||
} // SpdxExpression | ||
} |
Oops, something went wrong.