Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🚧Update to dotnet 8 #183

Merged
merged 3 commits into from
Nov 22, 2023
Merged
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
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Set the base image as the .NET 6.0 SDK (this includes the runtime)
FROM mcr.microsoft.com/dotnet/sdk:7.0 as build-env
# Set the base image as the .NET 8.0 SDK (this includes the runtime)
FROM mcr.microsoft.com/dotnet/sdk:8.0 as build-env

# Copy everything and publish the release (publish implicitly restores and builds)
COPY . ./
Expand All @@ -14,6 +14,6 @@ LABEL homepage="https://github.com/KinsonDigital/VersionMiner"
LABEL com.github.actions.name="Version Miner"

# Relayer the .NET SDK, anew with the build output
FROM mcr.microsoft.com/dotnet/sdk:7.0
FROM mcr.microsoft.com/dotnet/sdk:8.0
COPY --from=build-env /out .
ENTRYPOINT [ "dotnet", "/VersionMiner.dll" ]
31 changes: 16 additions & 15 deletions Testing/VersionMinerIntegrationTests/ExtensionMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
// </copyright>

using FluentAssertions;
using Xunit.Sdk;

namespace VersionMinerIntegrationTests;

using FluentAssertions.Execution;

/// <summary>
/// Provides extension methods for the unit test project.
/// </summary>
Expand Down Expand Up @@ -37,31 +38,31 @@ public static void SetPropertyValue<TObj, TPropValue>(this TObj? obj, string? pr
{
if (obj is null)
{
throw new AssertActualExpectedException(
expected: "Not Null",
actual: "Is Null",
$"The '{nameof(obj)}' parameter must not be null for this assertion to be completed.");
var exMsg = "Expected: Not Null";
exMsg += "\nActual: Is Null";
exMsg += $"\nThe '{nameof(obj)}' parameter must not be null for this assertion to be completed.";
throw new AssertionFailedException(exMsg);
}

if (string.IsNullOrEmpty(propName))
{
throw new AssertActualExpectedException(
expected: propName is null ? "Not Null" : "Not Empty",
actual: propName is null ? "Is Null" : "Is Empty",
$"The '{nameof(propName)}' parameter must not be null or empty for this assertion to be completed.");
var exMsg = $"Expected: {(propName is null ? "Not Null" : "Not Empty")}";
exMsg += $"Actual: {(propName is null ? "Is Null" : "Is Empty")}";
exMsg += $"pnThe '{nameof(propName)}' parameter must not be null or empty for this assertion to be completed.";

throw new AssertionFailedException(exMsg);
}

var foundProp = obj.GetType().Properties().FirstOrDefault(p => p.Name == propName && p.PropertyType == propValue.GetType());

if (foundProp is null)
{
var msg = $"The property '{propName}' on object '{obj.GetType().Name}' was not found or the property";
msg += " type does not match the parameter '{{nameof(propValue)}}' type.";
var exMsg = "Expected: Property to be found";
exMsg += "\nActual: Property was not found";
exMsg += $"\nThe property '{propName}' on object '{obj.GetType().Name}' was not found or the property";
exMsg += " type does not match the parameter '{{nameof(propValue)}}' type.";

throw new AssertActualExpectedException(
expected: "Property to be found",
actual: "Property was not found",
msg);
throw new AssertionFailedException(exMsg);
}

foundProp.SetValue(obj, propValue);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<LangVersion>11.0</LangVersion>
<LangVersion>12.0</LangVersion>
<IsPackable>false</IsPackable>
</PropertyGroup>

Expand Down
119 changes: 61 additions & 58 deletions Testing/VersionMinerTests/Helpers/ExtensionMethodsForTesting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@

using System.Reflection;
using CommandLine;
using Xunit.Sdk;

namespace VersionMinerTests.Helpers;

using FluentAssertions.Execution;

/// <summary>
/// Provides extension/helper methods to assist in unit testing.
/// </summary>
Expand All @@ -21,7 +22,7 @@ public static class ExtensionMethodsForTesting
/// <param name="propName">The name of the property on the object.</param>
/// <typeparam name="T">The type of attribute on the property.</typeparam>
/// <returns>The attribute if it exists.</returns>
/// <exception cref="AssertActualExpectedException">
/// <exception cref="AssertionFailedException">
/// Thrown if the property or attribute does not exist.
/// </exception>
public static T GetAttrFromProp<T>(this object value, string propName)
Expand All @@ -31,13 +32,13 @@ public static T GetAttrFromProp<T>(this object value, string propName)
var noPropsAssertMsg = string.IsNullOrEmpty(propName)
? $"Cannot get an attribute on a property when the '{nameof(propName)}' parameter is null or empty."
: $"Cannot get an attribute on a property when no property with the name '{propName}' exists.";
var noPropsExMsg = "Expected: at least 1 item";
noPropsExMsg += "\nActual: 0 items";
noPropsExMsg += $"\n{noPropsAssertMsg}";

if (props.Length <= 0)
{
throw new AssertActualExpectedException(
"at least 1 item.",
"was 0 items.",
noPropsAssertMsg);
throw new AssertionFailedException(noPropsExMsg);
}

var propNotFoundAssertMsg = $"Cannot get an attribute on the property '{propName}' if the property does not exist.";
Expand All @@ -47,21 +48,23 @@ public static T GetAttrFromProp<T>(this object value, string propName)

if (foundProp is null)
{
throw new AssertActualExpectedException(
"not to be null.",
"was null",
propNotFoundAssertMsg);
var notFoundPropExMsg = "Expected: not to be null";
notFoundPropExMsg += "\nActual: was null";
notFoundPropExMsg += $"\n{propNotFoundAssertMsg}";

throw new AssertionFailedException(notFoundPropExMsg);
}

var noAttrsAssertMsg = $"Cannot get an attribute when the property '{propName}' does not have any attributes.";
var attrs = foundProp.GetCustomAttributes<T>().ToArray();

if (attrs.Length <= 0)
{
throw new AssertActualExpectedException(
"at least 1 item.",
"was 0 items.",
noAttrsAssertMsg);
var noAttrsExMsg = "Expected: at least 1 item";
noAttrsExMsg += "\nActual: 0 items";
noAttrsExMsg += $"\n{noAttrsAssertMsg}";

throw new AssertionFailedException(noAttrsExMsg);
}

return attrs[0];
Expand All @@ -81,7 +84,7 @@ public static T GetAttrFromProp<T>(this object value, string propName)
/// <param name="requiredExpected">The expected value of the <see cref="OptionAttribute.Required"/> property.</param>
/// <param name="defaultExpected">The expected value of the <see cref="BaseAttribute.Default"/> property.</param>
/// <param name="helpTextExpected">The expected value of the <see cref="OptionAttribute.HelpText"/> property.</param>
/// <exception cref="AssertActualExpectedException">
/// <exception cref="AssertionFailedException">
/// Thrown if the any of the properties are not the correct values.
/// </exception>
public static void AssertOptionAttrProps(this OptionAttribute value,
Expand All @@ -92,33 +95,33 @@ public static void AssertOptionAttrProps(this OptionAttribute value,
{
if (value.LongName != longNameExpected)
{
throw new AssertActualExpectedException(
longNameExpected,
value.LongName,
throw new AssertionFailedException(
$"Expected: {longNameExpected}" +
"\nActual: value.LongName" +
$"The '{nameof(OptionAttribute)}.{nameof(OptionAttribute.LongName)}' property value is not correct for option '{longNameExpected}'.");
}

if (value.Required != requiredExpected)
{
throw new AssertActualExpectedException(
requiredExpected,
value.Required,
throw new AssertionFailedException(
$"{requiredExpected}" +
$"\n{value.Required}" +
$"The '{nameof(OptionAttribute)}.{nameof(OptionAttribute.Required)}' property value is not correct for option '{longNameExpected}'.");
}

if (value.Default.ToString() != defaultExpected.ToString())
{
throw new AssertActualExpectedException(
defaultExpected,
value.Default,
throw new AssertionFailedException(
$"{defaultExpected}" +
$"\n{value.Default}" +
$"The '{nameof(OptionAttribute)}.{nameof(OptionAttribute.Default)}' property value is not correct for option '{defaultExpected}'.");
}

if (value.HelpText != helpTextExpected)
{
throw new AssertActualExpectedException(
helpTextExpected,
value.HelpText,
throw new AssertionFailedException(
$"{helpTextExpected}" +
$"\n{value.HelpText}" +
$"The '{nameof(OptionAttribute)}.{nameof(OptionAttribute.HelpText)}' property value is not correct for option '{longNameExpected}'.");
}
}
Expand All @@ -135,7 +138,7 @@ public static void AssertOptionAttrProps(this OptionAttribute value,
/// <param name="longNameExpected">The expected value of the <see cref="OptionAttribute.LongName"/> property.</param>
/// <param name="requiredExpected">The expected value of the <see cref="OptionAttribute.Required"/> property.</param>
/// <param name="helpTextExpected">The expected value of the <see cref="OptionAttribute.HelpText"/> property.</param>
/// <exception cref="AssertActualExpectedException">
/// <exception cref="AssertionFailedException">
/// Thrown if any of the properties are not the correct values.
/// </exception>
public static void AssertOptionAttrProps(this OptionAttribute value,
Expand All @@ -145,25 +148,25 @@ public static void AssertOptionAttrProps(this OptionAttribute value,
{
if (value.LongName != longNameExpected)
{
throw new AssertActualExpectedException(
longNameExpected,
value.LongName,
throw new AssertionFailedException(
$"{longNameExpected}" +
$"\n{value.LongName}" +
$"The '{nameof(OptionAttribute)}.{nameof(OptionAttribute.LongName)}' property value is not correct for option '{longNameExpected}'.");
}

if (value.Required != requiredExpected)
{
throw new AssertActualExpectedException(
requiredExpected,
value.Required,
throw new AssertionFailedException(
$"{requiredExpected}" +
$"\n{value.Required}" +
$"The '{nameof(OptionAttribute)}.{nameof(OptionAttribute.Required)}' property value is not correct for option '{longNameExpected}'.");
}

if (value.HelpText != helpTextExpected)
{
throw new AssertActualExpectedException(
helpTextExpected,
value.HelpText,
throw new AssertionFailedException(
$"{helpTextExpected}" +
$"\n{value.HelpText}" +
$"The '{nameof(OptionAttribute)}.{nameof(OptionAttribute.HelpText)}' property value is not correct for option '{longNameExpected}'.");
}
}
Expand All @@ -179,7 +182,7 @@ public static void AssertOptionAttrProps(this OptionAttribute value,
/// <param name="value">The attribute to assert.</param>
/// <param name="longNameExpected">The expected value of the <see cref="OptionAttribute.LongName"/> property.</param>
/// <param name="helpTextExpected">The expected value of the <see cref="OptionAttribute.HelpText"/> property.</param>
/// <exception cref="AssertActualExpectedException">
/// <exception cref="AssertionFailedException">
/// Thrown if the any of the properties are not the correct values.
/// </exception>
public static void AssertOptionAttrProps(this OptionAttribute value,
Expand All @@ -188,17 +191,17 @@ public static void AssertOptionAttrProps(this OptionAttribute value,
{
if (value.LongName != longNameExpected)
{
throw new AssertActualExpectedException(
longNameExpected,
value.LongName,
throw new AssertionFailedException(
$"{longNameExpected}" +
$"\n{value.LongName}" +
$"The '{nameof(OptionAttribute)}.{nameof(OptionAttribute.LongName)}' property value is not correct.");
}

if (value.HelpText != helpTextExpected)
{
throw new AssertActualExpectedException(
helpTextExpected,
value.HelpText,
throw new AssertionFailedException(
$"{helpTextExpected}" +
$"\n{value.HelpText}" +
$"The '{nameof(OptionAttribute)}.{nameof(OptionAttribute.HelpText)}' property value is not correct.");
}
}
Expand All @@ -212,25 +215,25 @@ public static void AssertOptionAttrProps(this OptionAttribute value,
/// <param name="propValue">The value of the property.</param>
/// <typeparam name="TObj">The type of object.</typeparam>
/// <typeparam name="TPropValue">The type of property value.</typeparam>
/// <exception cref="AssertActualExpectedException">
/// <exception cref="AssertionFailedException">
/// Occurs if the parameters <paramref name="obj"/> or <paramref name="propName"/> are null.
/// Occurs if the property was not found.
/// </exception>
public static void SetPropValue<TObj, TPropValue>(this TObj obj, string propName, TPropValue propValue)
{
if (obj is null)
{
throw new AssertActualExpectedException(
"Not to be null.",
"Is null.",
throw new AssertionFailedException(
"Expected: Not to be null." +
"\nActual: Is null." +
$"The parameter '{nameof(propName)}' must not be null to set the property value");
}

if (string.IsNullOrEmpty(propName))
{
throw new AssertActualExpectedException(
"Not to be null or empty.",
"Is null or empty.",
throw new AssertionFailedException(
"Expected: Not to be null or empty." +
"\nActual: Is null or empty." +
$"The parameter '{nameof(propName)}' must not be null or empty to set the property value");
}

Expand All @@ -240,9 +243,9 @@ public static void SetPropValue<TObj, TPropValue>(this TObj obj, string propName

if (foundProp is null)
{
throw new AssertActualExpectedException(
"To exist.",
"Does not exit.",
throw new AssertionFailedException(
"Expected: To exist." +
"\nActual: Does not exit." +
$"A property with the name '{propName}' does not exit in the given '{nameof(obj)}' parameter");
}

Expand All @@ -252,10 +255,10 @@ public static void SetPropValue<TObj, TPropValue>(this TObj obj, string propName
}
catch (Exception e)
{
throw new AssertActualExpectedException(
$"Property '{propName}' value to be set.",
$"Property '{propName}' value was not set.",
$"Something went wrong with setting the property '{propName}' value in the '{obj}' parameter.\n{e.Message}");
throw new AssertionFailedException(
$"Expected: Property '{propName}' value to be set." +
$"\nActual: Property '{propName}' value was not set." +
$"\nSomething went wrong with setting the property '{propName}' value in the '{obj}' parameter.\n{e.Message}");
}
}
}
4 changes: 2 additions & 2 deletions Testing/VersionMinerTests/VersionMinerTests.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<LangVersion>11.0</LangVersion>
<TargetFramework>net8.0</TargetFramework>
<LangVersion>12.0</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
Expand Down
10 changes: 5 additions & 5 deletions VersionMiner/VersionMiner.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<LangVersion>11.0</LangVersion>
<TargetFramework>net8.0</TargetFramework>
<LangVersion>12.0</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<RootNamespace>VersionMiner</RootNamespace>
Expand Down Expand Up @@ -39,9 +39,9 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.FileSystemGlobbing" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="6.0.1" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.FileSystemGlobbing" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
<PackageReference Include="RestSharp" Version="108.0.3" />
<PackageReference Include="Octokit" Version="5.0.2" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
Expand Down
Loading