Skip to main content

Dependency insight for C#

org.openrewrite.csharp.dependencies.DependencyInsight

Finds dependencies in *.csproj and packages.config.

Recipe source

This recipe is only available to users of Moderne.

This recipe is available under the Moderne Proprietary License.

Options

TypeNameDescriptionExample
StringpackagePatternOptional. Package glob pattern used to match dependencies.Microsoft*
StringversionOptional. Match only dependencies with the specified version. Node-style version selectors may be used. All versions are searched by default.1.x

Example

Parameters
ParameterValue
packagePatternnull
versionnull
Before
<Project ToolsVersion="4.0" DefaultTargets="FullPublish" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<PackageReference Include="Contoso.Utility.UsefulStuff" Version="3.6.*" />
<PackageReference Include="Contoso.Utility.SomeOtherUsefulStuff" Version="3.6.0">
<ExcludeAssets>compile</ExcludeAssets>
<PrivateAssets>contentFiles</PrivateAssets>
</PackageReference>
</ItemGroup>
</Project>
After
<Project ToolsVersion="4.0" DefaultTargets="FullPublish" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<!--~~(Contoso.Utility.UsefulStuff:3.6.*)~~>--><PackageReference Include="Contoso.Utility.UsefulStuff" Version="3.6.*" />
<!--~~(Contoso.Utility.SomeOtherUsefulStuff:3.6.0)~~>--><PackageReference Include="Contoso.Utility.SomeOtherUsefulStuff" Version="3.6.0">
<ExcludeAssets>compile</ExcludeAssets>
<PrivateAssets>contentFiles</PrivateAssets>
</PackageReference>
</ItemGroup>
</Project>

Usage

This recipe has no required configuration options. Users of Moderne can run it via the Moderne CLI:

You will need to have configured the Moderne CLI on your machine before you can run the following command.

shell
mod run . --recipe DependencyInsight

If the recipe is not available locally, then you can install it using:

mod config recipes jar install org.openrewrite.recipe:rewrite-java-security:3.8.0

See how this recipe works across multiple open-source repositories

Run this recipe on OSS repos at scale with the Moderne SaaS.

The community edition of the Moderne platform enables you to easily run recipes across thousands of open-source repositories.

Please contact Moderne for more information about safely running the recipes on your own codebase in a private SaaS.

Data Tables

Dependencies in use

org.openrewrite.maven.table.DependenciesInUse

Direct and transitive dependencies in use.

Column NameDescription
Project nameThe name of the project that contains the dependency.
Source setThe source set that contains the dependency.
GroupThe first part of a dependency coordinate com.google.guava:guava:VERSION.
ArtifactThe second part of a dependency coordinate com.google.guava:guava:VERSION.
VersionThe resolved version.
Dated snapshot versionThe resolved dated snapshot version or null if this dependency is not a snapshot.
ScopeDependency scope. This will be compile if the dependency is direct and a scope is not explicitly specified in the POM.
DepthHow many levels removed from a direct dependency. This will be 0 for direct dependencies.

Contributors

Tim te Beek