Skip to content

Add LicenseUrl and LicenseExpression to NuspecReader - #273

Merged
jeffkl merged 1 commit into
jeffkl:mainfrom
MattKotsenas:bugfix/nuspec-license-url
Mar 8, 2024
Merged

jeffkl merged 1 commit into
jeffkl:mainfrom
MattKotsenas:bugfix/nuspec-license-url

Conversation

@MattKotsenas

@MattKotsenas MattKotsenas commented Mar 7, 2024 •

Copy link
Copy Markdown
Contributor

Add two new properties to NuspecReader:

  1. LicenseUrl
  2. LicenseExpression

LicenseUrl

Maps to the <licenseUrl> element, which can be set by the Package, but could never be read. Also update unit tests to validate values.

Note that as part of this PR I changed the domains for the sample URLs to use the TLD .invalid. While it really doesn't matter, using the .invalid TLD (reserved in RFC2606) is ever-so-slightly more correct, and avoids the possibility of accidentally trying to resolve these fake domains in the future.

LicenseExpression

A helper that returns the value of <license> if the license type is "expression". This centralizes what is otherwise a slightly gnarly ternary expression to disambiguate license expressions from license files:

string? licenseExpression = reader.LicenseType?.Equals("expression", StringComparison.OrdinalIgnoreCase) ?? false ? reader.License : null

The Package class currently can't create packages with a <license type="file">. This addition is a preparatory refactoring for an upcoming change to move the NuspecReader as an internal member of the main library.

Also added a unit test.

@MattKotsenas

Copy link
Copy Markdown
Contributor Author

I admit that the LicenseExpression change is a bit unjustified at the moment. I plan to stack another PR on top of this one that will use LicenseExpression and (hopefully) justify the change. If you object to that PR (or this portion of this PR) let me know and I can back the change out.

@jeffkl

jeffkl commented Mar 8, 2024

Copy link
Copy Markdown
Owner

Does this need to update the public APIs? The build passed so I guess not?

@MattKotsenas

Copy link
Copy Markdown
Contributor Author

Does this need to update the public APIs? The build passed so I guess not?

No because NuspecReader is in the unit test project and not the main lib. My upcoming PR moves this type to be internal to the main lib, hence the refactoring.

@jeffkl

jeffkl commented Mar 8, 2024

Copy link
Copy Markdown
Owner

Does this need to update the public APIs? The build passed so I guess not?

No because NuspecReader is in the unit test project and not the main lib. My upcoming PR moves this type to be internal to the main lib, hence the refactoring.

Ah sorry, been a long day where I've been looking at a lot of different things. I'll merge.

@jeffkl
jeffkl merged commit d94ac75 into jeffkl:main Mar 8, 2024
@MattKotsenas
MattKotsenas deleted the bugfix/nuspec-license-url branch March 8, 2024 03:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants