3580: AVRO-4214: [C#] Ensure nuget packages expose SPDX license expression#21
3580: AVRO-4214: [C#] Ensure nuget packages expose SPDX license expression#21martin-augment wants to merge 1 commit intomainfrom
Conversation
WalkthroughThis pull request modifies C# project packaging configuration and adds comprehensive NuGet package validation tests. The packaging metadata in common.props is updated to use PackageLicenseExpression instead of PackageLicenseFile. A new test suite is introduced in NuGetPackageTests.cs containing NUnit tests that validate package metadata for Apache Avro packages, specifically verifying SPDX license expressions, LICENSE file presence, and license file content. Helper methods extract package information from .nupkg archives. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Code Review SummaryThis PR implements AVRO-4214 to expose SPDX license expressions in NuGet packages. The changes are well-structured and include comprehensive test coverage. Positive Aspects
Potential Issues and Suggestions1. License File Still Included (By Design) 2. Test Discovery Path Complexity 3. Minor: Test Organization Security Considerations
Performance Considerations
Test CoverageExcellent test coverage with three complementary test methods:
All six packages are tested, providing comprehensive validation. Recommendations
Overall AssessmentLGTM - This is a well-implemented change with proper test coverage. The code follows C# and NuGet best practices, includes proper error handling, and thoroughly validates the license metadata changes. |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
lang/csharp/src/apache/test/NuGetPackageTests.cs (1)
121-135: Path discovery works, but comment/name could be clearer
FindPackageInBuildOutput’s strategy of walking up fromTestContext.CurrentContext.TestDirectoryand scanningSearchOption.AllDirectoriesforRelease.nupkgfiles is pragmatic and should work across TFMs. However, the comment says “Find the lang/csharp root” while the..chain actually lands at thesrclevel, and the variable namecsharpRootdoesn’t reflect that precisely. Consider tightening the comment (and optionally the variable name) to match the actual anchor directory.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
lang/csharp/common.props(1 hunks)lang/csharp/src/apache/test/NuGetPackageTests.cs(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Cursor Bugbot
- GitHub Check: claude-review
🔇 Additional comments (6)
lang/csharp/common.props (1)
47-56: SPDX license expression configuration looks correctUsing
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>alongside the packedLICENSEfile aligns with NuGet’s SPDX guidance and matches what the new tests expect. No issues from my side here.lang/csharp/src/apache/test/NuGetPackageTests.cs (5)
31-39: Good coverage over all relevant package IDsThe static
PackageIdsarray cleanly enumerates all Avro-related packages you care about, and drives the tests viaTestCaseSource, which keeps the suite easy to extend.
41-67: SPDX license expression assertion is solid and namespace‑safeThe nuspec parsing correctly handles XML namespaces and asserts both
type="expression"and value"Apache-2.0", with a clear inconclusive path when the package is missing. This gives strong validation of the new packaging metadata without being brittle.
69-90: LICENSE presence and non‑empty content checks are appropriateOpening the
.nupkgviaZipFile.OpenReadand asserting there is a non‑empty root entry namedLICENSEmatches how the packaging is configured and should catch accidental removal or renaming of the license file.
92-119: Text checks for Apache 2.0 are pragmatic and low‑maintenanceReading the LICENSE file and asserting that it contains both
"Apache License"and"Version 2.0"is a simple, robust way to guard against incorrect or truncated license content without overfitting to exact wording.
137-154: Nuspec extraction helper is clean and correctly scoped
ExtractNuspecFromPackagecleanly encapsulates the zip handling, guards on missing.nuspecwithAssert.Fail, and disposes streams correctly viausing. This keeps the test methods focused on assertions rather than I/O details.
3580: To review by AI