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,235 additions
and
72 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
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
13 changes: 13 additions & 0 deletions
13
...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,13 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netstandard2.1</TargetFramework> | ||
<Configurations>Debug;Release;TestWindows</Configurations> | ||
<Platforms>AnyCPU</Platforms> | ||
</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 | ||
} |
22 changes: 22 additions & 0 deletions
22
src/Tethys.SPDX.ExpressionParser/SpdxExpressionException.cs
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,22 @@ | ||
// 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 SpdxExpressionException : Exception | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="SpdxExpressionException"/> class. | ||
/// </summary> | ||
/// <param name="message">The message that describes the error.</param> | ||
public SpdxExpressionException(string message) | ||
: base(message) | ||
{ | ||
} // SpdxExpressionException() | ||
} // SpdxExpressionException | ||
} |
Oops, something went wrong.