Skip to content

Commit

Permalink
Merge pull request #7 from meokullu/new_version_0007
Browse files Browse the repository at this point in the history
v1.1.0
  • Loading branch information
meokullu authored Jun 24, 2024
2 parents 958d30d + 5f6a175 commit ec4baaf
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 17 deletions.
13 changes: 12 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,19 @@
#### Security
-->

### [1.0.0-rc] (2024-06-20)
### [1.1.0] (2024-06-24)
#### Added
* Override method of ToString() for `Package`. It displays package name and version.

#### Changed
* `GetPackageFromNuGetAsync(string packageName)` and `GetPackagesFromNuGetAsync(List<string> packageNameList)` methods are not using `package.Identity.Id` from `IPackageSearchMetadata` instead of requested package name when creating `Package` data for `Name`.
* `GetPackages(string path)` now checks if path is null or empty before parsing with `XmlDocument.Load()` and returns empty list of `Package` data.
* `CheckVersionAsync(string path)` now checks if path is null or empty and returns empty list of `Package` data.

### [1.0.0] (2024-06-23)
Initial release

### [1.0.0-rc] (2024-06-20)
#### Added
* `CheckVersionAsync(string path)` method added. This method return packages with their names, versions and available to update as a list.

Expand Down
15 changes: 9 additions & 6 deletions NuGetVersionChecker/NuGetVersionChecker.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,26 @@
<Company>Enes Okullu</Company>
<Description>NuGetVersionChecker is a track mechanism to compare versions of projects.</Description>
<RepositoryType>git</RepositoryType>
<PackageTags>version; version-checker; version-compare; NuGet; Nuget-Package; Dependency</PackageTags>
<PackageTags>version; version-checker; version-compare; NuGet; Nuget-Package; version-check; Dependency</PackageTags>
<PackageReleaseNotes>
v1.0.0
Initial release
v1.1.0
* GetPackageFromNuGetAsync() and GetPackagesFromNuGetAsync() now uses package.Identity.Id to fill Package data instead of using requested Package name.
* Package now has override ToString() method.
* GetPackages(string path) now check if path is null or empty.
* VersionCheckAsync(string path) now checks if path is null or empty.

See changelog (https://github.com/meokullu/NuGetVersionChecker/blob/master/CHANGELOG.md)
</PackageReleaseNotes>
<AssemblyVersion>1.0.0</AssemblyVersion>
<FileVersion>1.0.0</FileVersion>
<AssemblyVersion>1.1.0</AssemblyVersion>
<FileVersion>1.1.0</FileVersion>
<Title>Nuget Version Checker</Title>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageProjectUrl>https://meokullu.github.io/NuGetVersionChecker/</PackageProjectUrl>
<RepositoryUrl>https://github.com/meokullu/NuGetVersionChecker</RepositoryUrl>
<ApplicationIcon>Resources\icon256.ico</ApplicationIcon>
<Copyright>Enes Okullu</Copyright>
<PackageIcon>icon128.png</PackageIcon>
<Version>1.0.0</Version>
<Version>1.1.0</Version>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
</PropertyGroup>

Expand Down
8 changes: 4 additions & 4 deletions NuGetVersionChecker/src/GetPackageFromNuGet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public static async Task<Package> GetPackageFromNuGetAsync(string packageName)
}

// Get version info of list of the package.
IEnumerable<VersionInfo> versionInfoList = await package.GetVersionsAsync(); ;
IEnumerable<VersionInfo> versionInfoList = await package.GetVersionsAsync();

// Checking if versionInfoList is null or empty.
if (versionInfoList == null || versionInfoList.Any() == false)
Expand All @@ -63,7 +63,7 @@ public static async Task<Package> GetPackageFromNuGetAsync(string packageName)
VersionInfo versionInfo = versionInfoList.OrderByDescending(p => p.Version).First();

// Returning a Package via creating with its constructor.
return new Package(name: packageName, version: versionInfo.Version);
return new Package(name: package.Identity.Id, version: versionInfo.Version);
}

/// <summary>
Expand Down Expand Up @@ -101,7 +101,7 @@ public static async Task<List<Package>> GetPackagesFromNuGetAsync(List<string> p
}

// Get latest version info of newest version of the package.
IEnumerable<VersionInfo> versionInfoList = await package.GetVersionsAsync(); // OrderByDescending(p => p.Version).FirstOrDefault();
IEnumerable<VersionInfo> versionInfoList = await package.GetVersionsAsync();

// Checking if versionInfoList is null or empty.
if (versionInfoList == null || versionInfoList.Any() == false)
Expand All @@ -119,7 +119,7 @@ public static async Task<List<Package>> GetPackagesFromNuGetAsync(List<string> p
}

// Adding the Package via creating with its constructor.
packageList.Add(new Package(name: packageName, version: versionInfo.Version));
packageList.Add(new Package(name: package.Identity.Id, version: versionInfo.Version));
}

// Retuning list of packages as return data.
Expand Down
9 changes: 9 additions & 0 deletions NuGetVersionChecker/src/Package.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,15 @@ public Package(string name, SemanticVersion version, bool updateAvailable)
Version = version;
UpdateAvailable = updateAvailable;
}

/// <summary>
/// Override method of ToString(), simply displays package name and its version.
/// </summary>
/// <returns>Concat of package name and version.</returns>
public override string ToString()
{
return $"{Name} {Version}";
}
}
}
}
12 changes: 9 additions & 3 deletions NuGetVersionChecker/src/ParseFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,20 @@ public partial class NuGetVersionChecker
/// <returns>List of Packages.</returns>
public static List<Package> GetPackages(string path)
{
// Creating instance of XmlDocument.
XmlDocument xmldoc = new XmlDocument();

// Creating list of empty packages.
List<Package> packages = new List<Package>();

// Checking if path is null or empty.
if (string.IsNullOrEmpty(path))
{
return packages;
}

try
{
// Creating instance of XmlDocument.
XmlDocument xmldoc = new XmlDocument();

// Loading file with specified path.
xmldoc.Load(path);

Expand Down
12 changes: 9 additions & 3 deletions NuGetVersionChecker/src/VersionChecker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,21 @@ public partial class NuGetVersionChecker
/// <returns>List of Packages.</returns>
public static async Task<List<Package>> CheckVersionAsync(string path)
{
// Returning data which consisting packages.
List<Package> packages = new List<Package>();

// Checking if path is null or empty.
if (string.IsNullOrEmpty(path))
{
return packages;
}

// Get currently used packages.
List<Package> usedPackages = GetPackages(path);

// Get used packages info from NuGet.
List<Package> nugetPackages = await GetPackagesFromNuGetAsync(usedPackages.Select(p => p.Name).ToList());

// Returning data which consisting packages.
List<Package> packages = new List<Package>();

// Loop for packages
foreach (Package package in usedPackages)
{
Expand Down

0 comments on commit ec4baaf

Please sign in to comment.