Add config file class for C# nuget `*.csproj`
What does this MR do and why?
Background
The Repository X-Ray is a tool that searches for dependency manager configuration or lock files and then extracts a list of libraries from the content.
In #474306 (comment 2025085630), we decided to migrate the Repository X-Ray functionality into the GitLab Rails monolith. This gives us two main benefits: (i) it will eventually allow us to run the service outside of the CI pipeline, and (ii) we can maintain the parsing logic centrally so that other domains can utilize it.
Base MR
In !162313 (merged), we introduced the ConfigFiles::Base
class where the intention is for each dependency manager config file type to be represented by a child class. The child class contains the parsing logic to extract a list of libraries and their versions from the file content.
This MR
In this MR, we introduce the CsharpNuget
config file class that parses *.csproj
for the language C#
.
For references to the existing parsing logic in the Repository X-Ray repo, see:
- https://gitlab.com/gitlab-org/code-creation/repository-x-ray/-/blob/6634564818dffdeac938014a190b0c604b1da6e0/internal/scanner/scanner.go#L38
- https://gitlab.com/gitlab-org/code-creation/repository-x-ray/-/blob/6634564818dffdeac938014a190b0c604b1da6e0/internal/scanner/scanner.go#L378
Resolves part of #476177 (closed).
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
How to set up and validate locally
-
Enable the feature flag:
Feature.enable(:ai_enable_internal_repository_xray_service)
-
Create a new blank project and add the following file to the repo:
subdir/MyProj.csproj
:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="6.0.1" />
<PackageReference Include="MessagePack" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Sentry" Version="5.3.1" PrivateAssets="All" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..local/.Date.csproj" />
</ItemGroup>
<ItemGroup>
<None Include="artifacts-icon.png" Pack="true" />
<None Include="README.md" Pack="true" />
</ItemGroup>
</Project>
- Observe that the X-ray report for the config file is recorded:
project = Project.last # Should be the project you created earlier
project.reload.xray_reports
Related to #476177 (closed)
Merge request reports
Activity
changed milestone to %17.5
mentioned in issue #476177 (closed)
assigned to @lma-git
2 Messages CHANGELOG missing: If this merge request needs a changelog entry, add the
Changelog
trailer to the commit message you want to add to the changelog.If this merge request doesn't need a CHANGELOG entry, feel free to ignore this message.
This merge request adds or changes documentation files. A review from the Technical Writing team before you merge is recommended. Reviews can happen after you merge. Documentation review
The following files require a review from a technical writer:
-
doc/user/project/repository/code_suggestions/repository_xray.md
(Link to current live version)
The review does not need to block merging this merge request. See the:
-
Metadata for the
*.md
files that you've changed. The first few lines of each*.md
file identify the stage and group most closely associated with your docs change. - The Technical Writer assigned for that stage and group.
- Documentation workflows for information on when to assign a merge request for review.
Reviewer roulette
Category Reviewer Maintainer backend @paulobarros
(UTC+2, 9 hours ahead of author)
@jessieay
(UTC-7, same timezone as author)
Please refer to documentation page for guidance on how you can benefit from the Reviewer Roulette, or use the GitLab Review Workload Dashboard to find other available reviewers.
If needed, you can retry the
danger-review
job that generated this comment.Generated by
Danger-
- Resolved by Hunter Stewart
Hi @praba.m7n! Could you please do the first backend review here? Please send to a maintainer if it looks okay to you. Thanks!
requested review from @praba.m7n
- Resolved by Hunter Stewart
added 215 commits
-
91d8f73d...0386c734 - 213 commits from branch
master
- 8ca3ae65 - Add C# nuget config file class
- 0cf7f419 - Update repository x-ray supported lang table
-
91d8f73d...0386c734 - 213 commits from branch
- A deleted user
added documentation label
requested review from @imand3r and removed review request for @praba.m7n
requested review from @hustewart
added pipeline:mr-approved label
added pipelinetier-2 label
mentioned in issue gitlab-com/www-gitlab-com#13970 (closed)
added pipelinetier-3 pipeline:run-e2e-omnibus-once labels and removed pipelinetier-2 label
Before you set this MR to auto-merge
This merge request will progress on pipeline tiers until it reaches the last tier: pipelinetier-3. We will trigger a new pipeline for each transition to a higher tier.
Before you set this MR to auto-merge, please check the following:
- You are the last maintainer of this merge request
- The latest pipeline for this merge request is pipelinetier-3 (You can find which tier it is in the pipeline name)
- This pipeline is recent enough (created in the last 8 hours)
If all the criteria above apply, please set auto-merge for this merge request.
See pipeline tiers and merging a merge request for more details.
E2E Test Result Summary
allure-report-publisher
generated test report!e2e-test-on-gdk:
test report for 0cf7f419expand test summary
+------------------------------------------------------------------+ | suites summary | +-------------+--------+--------+---------+-------+-------+--------+ | | passed | failed | skipped | flaky | total | result | +-------------+--------+--------+---------+-------+-------+--------+ | Data Stores | 33 | 0 | 1 | 0 | 34 | ✅ | | Package | 24 | 0 | 11 | 0 | 35 | ✅ | | Release | 5 | 0 | 0 | 0 | 5 | ✅ | | Create | 128 | 0 | 17 | 0 | 145 | ✅ | | Plan | 75 | 0 | 1 | 1 | 76 | ✅ | | Verify | 46 | 0 | 2 | 0 | 48 | ✅ | | Secure | 4 | 0 | 0 | 0 | 4 | ✅ | | Govern | 72 | 0 | 0 | 0 | 72 | ✅ | | Monitor | 8 | 0 | 0 | 0 | 8 | ✅ | | Analytics | 2 | 0 | 0 | 0 | 2 | ✅ | | Manage | 1 | 0 | 1 | 0 | 2 | ✅ | | Fulfillment | 2 | 0 | 0 | 0 | 2 | ✅ | +-------------+--------+--------+---------+-------+-------+--------+ | Total | 400 | 0 | 33 | 1 | 433 | ✅ | +-------------+--------+--------+---------+-------+-------+--------+
e2e-test-on-omnibus:
test report for 0cf7f419expand test summary
+-------------------------------------------------------------+ | suites summary | +--------+--------+--------+---------+-------+-------+--------+ | | passed | failed | skipped | flaky | total | result | +--------+--------+--------+---------+-------+-------+--------+ | Create | 553 | 1 | 76 | 2 | 630 | ❌ | +--------+--------+--------+---------+-------+-------+--------+ | Total | 553 | 1 | 76 | 2 | 630 | ❌ | +--------+--------+--------+---------+-------+-------+--------+
removed pipeline:run-e2e-omnibus-once label
started a merge train
mentioned in commit 896f8a79
added workflowstaging-canary label and removed workflowin review label
added workflowcanary label and removed workflowstaging-canary label
added workflowstaging label and removed workflowcanary label
added workflowproduction label and removed workflowstaging label
added workflowpost-deploy-db-staging label and removed workflowproduction label
added workflowpost-deploy-db-production label and removed workflowpost-deploy-db-staging label
added releasedcandidate label
added releasedpublished label and removed releasedcandidate label