Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion NOTICE
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Net-Project-Package-Extractor
Copyright 2022-2024 Starion Group S.A.
Copyright 2022-2025 Starion Group S.A.
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public async Task Verify_that_InvokeAsync_returns_0()
this.projectFileExtractor.Verify(x => x.QueryProjectFiles(It.IsAny<DirectoryInfo>()),
Times.Once);

this.projectFileParser.Verify(x => x.Parse(It.IsAny<IEnumerable<FileInfo>>()
this.projectFileParser.Verify(x => x.Parse(It.IsAny<IEnumerable<FileInfo>>(), It.IsAny<DirectoryInfo>()
), Times.Once);

Assert.That(result, Is.EqualTo(0));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
<Company>Starion Group S.A.</Company>
<Authors>Sam Gerené, Alexander van Delft</Authors>
<Copyright>Copyright 2022-2024 Starion Group S.A.</Copyright>
<Authors>Sam Gerené, Alexander van Delft, Anh Toan Bui Long</Authors>
<Copyright>Copyright 2022-2025 Starion Group S.A.</Copyright>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.0" />
<PackageReference Include="Moq" Version="4.20.72" />
<PackageReference Include="NUnit" Version="4.2.2" />
<PackageReference Include="NUnit" Version="4.3.2" />
<PackageReference Include="NUnit.Console" Version="3.18.2" />
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0" />
<PackageReference Include="coverlet.collector" Version="6.0.2">
<PackageReference Include="coverlet.collector" Version="3.1.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand All @@ -28,12 +28,26 @@
<ItemGroup>
<Folder Include="Commands\" />
<Folder Include="Root\SubFolder1\Subfolder1.1\" />
<Folder Include="Root\SubFolder1\Subfolder1.2\SubsubFolder1.2.1\SubSubSubFolder1.2.1.1\" />
</ItemGroup>

<ItemGroup>
<None Include="Root\root.csproj">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Root\SubFolder1\Subfolder1.2\SubFolder1.2.csproj">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Root\SubFolder1\Subfolder1.2\SubsubFolder1.2.1\SubSubSubFolder1.2.1.1\SubSubSubFolder1.2.1.1.csproj">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Root\SubFolder1\Subfolder1.2\Directory.Packages.props">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="root\subfolder1\subfolder1.2\subsubfolder1.2.1\SubSubFolder1.2.1.csproj">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>

<None Include="Root\SubFolder1\SubFolder1.csproj">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// -------------------------------------------------------------------------------------------------
// <copyright file="ResourceLoaderTestFixture.cs" company="Starion Group S.A.">
//
// Copyright 2022-2024 Starion Group S.A.
// Copyright 2022-2025 Starion Group S.A.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project>
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<CentralPackageTransitivePinningEnabled>false</CentralPackageTransitivePinningEnabled>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="NUnit3TestAdapter" Version="4.3.0" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<ImplicitUsings>disable</ImplicitUsings>
<Title>SubFolder1.2 Project</Title>
<PackageId>SubFolder1.2-Project</PackageId>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="NUnit3TestAdapter" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<ImplicitUsings>disable</ImplicitUsings>
<Title>SubFolder1.2 Project</Title>
<PackageId>SubFolder1.2-Project</PackageId>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="NUnit3TestAdapter" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<ImplicitUsings>disable</ImplicitUsings>
<Title>SubFolder1.2 Project</Title>
<PackageId>SubFolder1.2-Project</PackageId>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="NUnit3TestAdapter" VersionOverride="4.5.0"/>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
// -------------------------------------------------------------------------------------------------
// <copyright file="DirectoryPackageParserTestFixture.cs" company="Starion Group S.A.">
//
// Copyright 2022-2025 Starion Group S.A.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// </copyright>
// ------------------------------------------------------------------------------------------------


namespace NetProjectPackageExtractor.Tests.Services
{
using System;
using System.IO;
using System.Collections.Generic;

using NetProjectPackageExtractor;
using NetProjectPackageExtractor.Services;

using NUnit.Framework;

/// <summary>
/// Suite of tests for the <see cref="DirectoryPackageParser"/> class.
/// </summary>
[TestFixture]

public class DirectoryPackageParserTestFixture
{
private DirectoryPackageParser directoryPackageParser;

private List<Package> packages;

private DirectoryInfo rootFolder;

[SetUp]
public void SetUp()
{
this.rootFolder = new DirectoryInfo(Path.Combine(TestContext.CurrentContext.TestDirectory, "Root"));
}

/// <summary>
/// This tests if it is able to find the package management in the parent folders
/// </summary>
[Test]
[Category("DirectoryPackageParser")]
public void Verify_that_Parser_returns_packages()
{
var targetProjectFile = new FileInfo(Path.Combine(this.rootFolder.FullName, "SubFolder1", "Subfolder1.2", "SubsubFolder1.2.1", "SubSubSubFolder1.2.1.1", "SubSubSubFolder1.2.1.1.csproj"));
var dictionnary = DirectoryPackageParser.SearchAndParse(targetProjectFile, this.rootFolder);
Assert.That(dictionnary["NUnit3TestAdapter"], Is.EqualTo("4.3.0"));
}

/// <summary>
/// This tests if it is able to find the package management in the parent folders
/// </summary>
[Test]
[Category("DirectoryPackageParser")]
public void Verify_that_Parser_returns_packages_from_subfolder()
{
var targetProjectFile = new FileInfo(Path.Combine(this.rootFolder.FullName, "SubFolder1", "Subfolder1.2", "SubsubFolder1.2.1", "SubSubFolder1.2.1.csproj"));
var dictionnary = DirectoryPackageParser.SearchAndParse(targetProjectFile, this.rootFolder);
Assert.That(dictionnary["NUnit3TestAdapter"], Is.EqualTo("4.3.0"));
}

/// <summary>
/// This tests if it is able to find the package management in the same folder
/// </summary>
[Test]
[Category("DirectoryPackageParser")]
public void Verify_that_Parser_returns_packages_in_same_folder()
{
var targetProjectFile = new FileInfo(Path.Combine(this.rootFolder.FullName, "SubFolder1", "Subfolder1.2", "SubFolder1.2.csproj"));
var dictionnary = DirectoryPackageParser.SearchAndParse(targetProjectFile, this.rootFolder);
Assert.That(dictionnary["NUnit3TestAdapter"], Is.EqualTo("4.3.0"));
}

/// <summary>
/// This tests if the project file has no directory.packages.props files in the parent folders
/// </summary>
[Test]
[Category("DirectoryPackageParser")]
public void Verify_that_Parser_returns_nothing()
{
var targetProjectFile = new FileInfo(Path.Combine(this.rootFolder.FullName, "root.csproj"));
var dictionary = DirectoryPackageParser.SearchAndParse(targetProjectFile, this.rootFolder);
Assert.That(dictionary.Count, Is.EqualTo(0));
}

/// <summary>
/// This tests if the project file is in a parent folder of the target folder
/// </summary>
[Test]
[Category("DirectoryPackageParser")]
public void Verify_that_Parser_returns_exception()
{
var targetProjectFile = new FileInfo(Path.Combine(this.rootFolder.FullName, "root.csproj"));
var targetFolderFile = new DirectoryInfo(Path.Combine(this.rootFolder.FullName, "SubFolder1"));

Assert.Throws<ArgumentException>(() => DirectoryPackageParser.SearchAndParse(targetProjectFile, targetFolderFile));
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// -------------------------------------------------------------------------------------------------
// <copyright file="NuGetReaderTestFixture.cs" company="Starion Group S.A.">
//
// Copyright 2022-2024 Starion Group S.A.
// Copyright 2022-2025 Starion Group S.A.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// -------------------------------------------------------------------------------------------------
// <copyright file="PackageToExcelWriterTestFixture.cs" company="Starion Group S.A.">
//
// Copyright 2022-2024 Starion Group S.A.
// Copyright 2022-2025 Starion Group S.A.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// -------------------------------------------------------------------------------------------------
// <copyright file="ProjectFileExtractorTestFixture.cs" company="Starion Group S.A.">
//
// Copyright 2022-2024 Starion Group S.A.
// Copyright 2022-2025 Starion Group S.A.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -50,7 +50,7 @@ public void Verify_that_The_project_files_are_found()
{
var files = this.projectFileExtractor.QueryProjectFiles(rootFolder);

Assert.That(files.Count(), Is.EqualTo(3));
Assert.That(files.Count(), Is.EqualTo(6));
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// -------------------------------------------------------------------------------------------------
// <copyright file="ProjectFileParserTestFixture.cs" company="Starion Group S.A.">
//
// Copyright 2022-2024 Starion Group S.A.
// Copyright 2022-2025 Starion Group S.A.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -38,20 +38,24 @@ public class ProjectFileParserTestFixture

private List<FileInfo> projectFiles;

private DirectoryInfo rootFolder;

[SetUp]
public void Setup()
{
var projectFile = Path.Combine(TestContext.CurrentContext.TestDirectory, "Root", "root.csproj");
var projectFile = Path.Combine(TestContext.CurrentContext.TestDirectory, "Root", "root.csproj");

this.rootFolder = new DirectoryInfo(Path.GetDirectoryName(projectFile));

this.projectFiles = new List<FileInfo>() { new FileInfo(projectFile) };
this.projectFiles = [new FileInfo(projectFile)];

this.projectFileParser = new ProjectFileParser();
}

[Test]
public void Verify_that_Parser_returns_packages()
{
var package = this.projectFileParser.Parse(projectFiles).Single();
var package = this.projectFileParser.Parse(projectFiles, rootFolder).Single();

Assert.That(package.ProjectTitle, Is.EqualTo("Root project"));
Assert.That(package.ProjectVersion, Is.EqualTo("0.0.1"));
Expand Down
5 changes: 4 additions & 1 deletion NetProjectPackageExtractor.sln.DotSettings
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateInstanceFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String></wpf:ResourceDictionary>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/UserRules/=4a98fdf6_002D7d98_002D4f5a_002Dafeb_002Dea44ad98c70c/@EntryIndexedValue">&lt;Policy&gt;&lt;Descriptor Staticness="Instance" AccessRightKinds="Private" Description="Instance fields (private)"&gt;&lt;ElementKinds&gt;&lt;Kind Name="FIELD" /&gt;&lt;Kind Name="READONLY_FIELD" /&gt;&lt;/ElementKinds&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="True" WarnAboutPrefixesAndSuffixes="False" Prefix="" Suffix="" Style="aaBb" /&gt;&lt;/Policy&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/UserRules/=f9fce829_002De6f4_002D4cb2_002D80f1_002D5497c44f51df/@EntryIndexedValue">&lt;Policy&gt;&lt;Descriptor Staticness="Static" AccessRightKinds="Private" Description="Static fields (private)"&gt;&lt;ElementKinds&gt;&lt;Kind Name="FIELD" /&gt;&lt;/ElementKinds&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="True" WarnAboutPrefixesAndSuffixes="False" Prefix="" Suffix="" Style="aaBb" /&gt;&lt;/Policy&gt;</s:String>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EPredefinedNamingRulesToUserRulesUpgrade/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
10 changes: 5 additions & 5 deletions NetProjectPackageExtractor/Commands/ExtractCommand.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// -------------------------------------------------------------------------------------------------
// <copyright file="ExtractCommand.cs" company="Starion Group S.A.">
//
// Copyright 2022-2024 Starion Group S.A.
// Copyright 2022-2025 Starion Group S.A.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -89,10 +89,10 @@ public ExtractCommand() : base("Package Extractor")

/// <summary>
/// The (injected) <see cref="IProjectFileExtractor"/> used to recursively iterate through a directory
/// tree and return all the .csproj files in this directory tree as an List of <see cref="FileInfo"/> objects
/// tree and return all the .csproj files in this directory tree as a List of <see cref="FileInfo"/> objects
/// </summary>
private readonly IProjectFileExtractor projectFileExtractor;

/// <summary>
/// The (injected) <see cref="IProjectFileParser"/> used to parses a project file and extract the
/// referenced nuget packages
Expand Down Expand Up @@ -194,8 +194,8 @@ await AnsiConsole.Status()
Thread.Sleep(1500);

var csprojFiles = this.projectFileExtractor.QueryProjectFiles(this.RootDirectory);
var packages = projectFileParser.Parse(csprojFiles).ToList();

var packages = projectFileParser.Parse(csprojFiles, this.RootDirectory).ToList();

AnsiConsole.MarkupLine($"[grey]LOG:[/] A total of [bold]{packages.Count}[/] packages were read");
ctx.Status("Updating Package information at Warp 7...");
Expand Down
2 changes: 1 addition & 1 deletion NetProjectPackageExtractor/Model/Package.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// -------------------------------------------------------------------------------------------------
// <copyright file="Package.cs" company="Starion Group S.A.">
//
// Copyright 2022-2024 Starion Group S.A.
// Copyright 2022-2025 Starion Group S.A.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
6 changes: 3 additions & 3 deletions NetProjectPackageExtractor/NetProjectPackageExtractor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<PackageId>nppe</PackageId>
<ToolCommandName>nppe</ToolCommandName>
<PackageOutputPath>./nupkg</PackageOutputPath>
<Version>4.0.0</Version>
<Version>4.1.0</Version>
<ImplicitUsings>disable</ImplicitUsings>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageIcon>starion-s-symbol-main1-rgb.png</PackageIcon>
Expand All @@ -20,8 +20,8 @@

<PropertyGroup Label="Copyright">
<Company>Starion Group S.A.</Company>
<Copyright>Copyright 2022-2024 Starion Group S.A.</Copyright>
<Authors>Sam Gerené, Alexander van Delft</Authors>
<Copyright>Copyright 2022-2025 Starion Group S.A.</Copyright>
<Authors>Sam Gerené, Alexander van Delft, Anh Toan Bui Long</Authors>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<RequireLicenseAcceptance>true</RequireLicenseAcceptance>
</PropertyGroup>
Expand Down
Loading