Skip to content

Commit

Permalink
net8
Browse files Browse the repository at this point in the history
  • Loading branch information
petrsvihlik committed Feb 24, 2024
1 parent c1ff0aa commit 065be0e
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 63 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/integrate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.0.x
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.0.x
dotnet-version: 8.0.x
- name: Extract version from tag
id: get_version
uses: battila7/get-version-action@v2
Expand Down
6 changes: 4 additions & 2 deletions jsConnect.sln
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29411.108
# Visual Studio Version 17
VisualStudioVersion = 17.9.34616.47
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{0EB0E003-5911-4A1F-A4FE-27A046C69D1A}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{06DB3DBE-1BB3-4D9F-9FD9-3AD7E9F07967}"
ProjectSection(SolutionItems) = preProject
.gitignore = .gitignore
.github\workflows\integrate.yml = .github\workflows\integrate.yml
README.md = README.md
.github\workflows\release.yml = .github\workflows\release.yml
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "jsConnect", "src\jsConnect\jsConnect.csproj", "{912C9673-A2BE-4841-80DE-4927B00D4AAB}"
Expand Down
2 changes: 1 addition & 1 deletion src/jsConnect.Tests/jsConnect.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
15 changes: 4 additions & 11 deletions src/jsConnect/Controllers/AbstractControllerBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,10 @@ namespace jsConnect.Controllers
/// <summary>
/// Base controller containing default shared functionality.
/// </summary>
public abstract class AbstractControllerBase<T> : Controller
public abstract class AbstractControllerBase<T>(IConfiguration configuration, ILogger<T> logger, ILoggerFactory loggerFactory) : Controller

Check warning on line 10 in src/jsConnect/Controllers/AbstractControllerBase.cs

View check run for this annotation

Codecov / codecov/patch

src/jsConnect/Controllers/AbstractControllerBase.cs#L10

Added line #L10 was not covered by tests
{
protected IConfiguration Configuration { get; set; }
protected ILogger<T> Logger { get; set; }
protected ILoggerFactory LoggerFactory { get; set; }

protected AbstractControllerBase(IConfiguration configuration, ILogger<T> logger, ILoggerFactory loggerFactory)
{
Configuration = configuration;
Logger = logger;
LoggerFactory = loggerFactory;
}
protected IConfiguration Configuration { get; set; } = configuration;

Check warning on line 12 in src/jsConnect/Controllers/AbstractControllerBase.cs

View workflow job for this annotation

GitHub Actions / build

Missing XML comment for publicly visible type or member 'AbstractControllerBase<T>.Configuration'

Check warning on line 12 in src/jsConnect/Controllers/AbstractControllerBase.cs

View workflow job for this annotation

GitHub Actions / build

Missing XML comment for publicly visible type or member 'AbstractControllerBase<T>.Configuration'

Check warning on line 12 in src/jsConnect/Controllers/AbstractControllerBase.cs

View workflow job for this annotation

GitHub Actions / build

Missing XML comment for publicly visible type or member 'AbstractControllerBase<T>.Configuration'
protected ILogger<T> Logger { get; set; } = logger;

Check warning on line 13 in src/jsConnect/Controllers/AbstractControllerBase.cs

View workflow job for this annotation

GitHub Actions / build

Missing XML comment for publicly visible type or member 'AbstractControllerBase<T>.Logger'

Check warning on line 13 in src/jsConnect/Controllers/AbstractControllerBase.cs

View workflow job for this annotation

GitHub Actions / build

Missing XML comment for publicly visible type or member 'AbstractControllerBase<T>.Logger'

Check warning on line 13 in src/jsConnect/Controllers/AbstractControllerBase.cs

View workflow job for this annotation

GitHub Actions / build

Missing XML comment for publicly visible type or member 'AbstractControllerBase<T>.Logger'
protected ILoggerFactory LoggerFactory { get; set; } = loggerFactory;

Check warning on line 14 in src/jsConnect/Controllers/AbstractControllerBase.cs

View workflow job for this annotation

GitHub Actions / build

Missing XML comment for publicly visible type or member 'AbstractControllerBase<T>.LoggerFactory'

Check warning on line 14 in src/jsConnect/Controllers/AbstractControllerBase.cs

View check run for this annotation

Codecov / codecov/patch

src/jsConnect/Controllers/AbstractControllerBase.cs#L12-L14

Added lines #L12 - L14 were not covered by tests

Check warning on line 14 in src/jsConnect/Controllers/AbstractControllerBase.cs

View workflow job for this annotation

GitHub Actions / build

Missing XML comment for publicly visible type or member 'AbstractControllerBase<T>.LoggerFactory'

Check warning on line 14 in src/jsConnect/Controllers/AbstractControllerBase.cs

View workflow job for this annotation

GitHub Actions / build

Missing XML comment for publicly visible type or member 'AbstractControllerBase<T>.LoggerFactory'
}
}
10 changes: 2 additions & 8 deletions src/jsConnect/Controllers/JsConnectController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace jsConnect.Controllers
/// Authentication endpoint implemented in accordance with http://docs.vanillaforums.com/help/sso/jsconnect/seamless/.
/// </summary>
[Route("[controller]")]
public class JsConnectController : AbstractControllerBase<JsConnectController>
public class JsConnectController(IConfiguration configuration, ILogger<JsConnectController> logger, ILoggerFactory loggerFactory, HashAlgorithm hashAlgorithm) : AbstractControllerBase<JsConnectController>(configuration, logger, loggerFactory)

Check warning on line 21 in src/jsConnect/Controllers/JsConnectController.cs

View check run for this annotation

Codecov / codecov/patch

src/jsConnect/Controllers/JsConnectController.cs#L21

Added line #L21 was not covered by tests
{
#region "Configuration"

Expand Down Expand Up @@ -61,13 +61,7 @@ public class JsConnectController : AbstractControllerBase<JsConnectController>

#endregion

private HashAlgorithm HashAlgorithm { get; set; }


public JsConnectController(IConfiguration configuration, ILogger<JsConnectController> logger, ILoggerFactory loggerFactory, HashAlgorithm hashAlgorithm) : base(configuration, logger, loggerFactory)
{
HashAlgorithm = hashAlgorithm;
}
private HashAlgorithm HashAlgorithm { get; set; } = hashAlgorithm;

Check warning on line 64 in src/jsConnect/Controllers/JsConnectController.cs

View check run for this annotation

Codecov / codecov/patch

src/jsConnect/Controllers/JsConnectController.cs#L64

Added line #L64 was not covered by tests

/// <summary>
/// Returns details of a currently signed-in user, if any.
Expand Down
26 changes: 7 additions & 19 deletions src/jsConnect/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,8 @@ public static string ToJsonp(this object o, string callback)
{
throw new ArgumentNullException(nameof(callback), "Callback parameter must be initialized.");
}
if (o == null)
{
throw new ArgumentNullException(nameof(o));
}
var settings = new JsonSerializerSettings
ArgumentNullException.ThrowIfNull(o);
var settings = new JsonSerializerSettings

Check warning on line 26 in src/jsConnect/Extensions.cs

View check run for this annotation

Codecov / codecov/patch

src/jsConnect/Extensions.cs#L25-L26

Added lines #L25 - L26 were not covered by tests
{
NullValueHandling = NullValueHandling.Ignore
};
Expand All @@ -50,22 +47,16 @@ public static int Timestamp(this DateTime dt)
/// <param name="buff">Array to convert.</param>
public static string ToHexString(this byte[] buff)
{
if (buff == null)
{
throw new ArgumentNullException(nameof(buff));
}
return buff.Aggregate("", (current, t) => current + t.ToString("x2"));
ArgumentNullException.ThrowIfNull(buff);
return buff.Aggregate("", (current, t) => current + t.ToString("x2"));

Check warning on line 51 in src/jsConnect/Extensions.cs

View check run for this annotation

Codecov / codecov/patch

src/jsConnect/Extensions.cs#L50-L51

Added lines #L50 - L51 were not covered by tests
}

/// <summary>
/// Encodes URL according to RFC1738 (http://www.ietf.org/rfc/rfc1738.txt). In addition, it encodes $-_.+!*'() characters.
/// </summary>
public static string UrlEncode(this string s)
{
if (s == null)
{
throw new ArgumentNullException(nameof(s));
}
ArgumentNullException.ThrowIfNull(s);

Check warning on line 59 in src/jsConnect/Extensions.cs

View check run for this annotation

Codecov / codecov/patch

src/jsConnect/Extensions.cs#L59

Added line #L59 was not covered by tests
static string me(Match m) => m.ToString().ToUpper();

string result = WebUtility.UrlEncode(s);
Expand All @@ -86,11 +77,8 @@ public static string UrlEncode(this string s)
/// <returns>Returns value if the given key exists. Otherwise, returns a default value of <see cref="L"/>.</returns>

Check warning on line 77 in src/jsConnect/Extensions.cs

View workflow job for this annotation

GitHub Actions / build

XML comment has cref attribute 'L' that could not be resolved

Check warning on line 77 in src/jsConnect/Extensions.cs

View workflow job for this annotation

GitHub Actions / build

XML comment has cref attribute 'L' that could not be resolved

Check warning on line 77 in src/jsConnect/Extensions.cs

View workflow job for this annotation

GitHub Actions / build

XML comment has cref attribute 'L' that could not be resolved
public static L GetValue<T, L>(this Dictionary<T, L> dic, T key)
{
if (dic == null)
{
throw new ArgumentNullException(nameof(dic));
}
if (dic.TryGetValue(key, out L value))
ArgumentNullException.ThrowIfNull(dic);

Check warning on line 80 in src/jsConnect/Extensions.cs

View check run for this annotation

Codecov / codecov/patch

src/jsConnect/Extensions.cs#L80

Added line #L80 was not covered by tests
if (dic.TryGetValue(key, out L value))
{
return value;
}
Expand Down
31 changes: 13 additions & 18 deletions src/jsConnect/JsConnectException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@

namespace jsConnect
{
/// <summary>
/// Exception object containing parameters expected by Vanilla Forums.
/// </summary>
public class JsConnectException : Exception
/// <summary>
/// Exception object containing parameters expected by Vanilla Forums.
/// </summary>
/// <remarks>
/// Default constructor.
/// </remarks>
public class JsConnectException(string error, string message) : Exception(message)

Check warning on line 11 in src/jsConnect/JsConnectException.cs

View check run for this annotation

Codecov / codecov/patch

src/jsConnect/JsConnectException.cs#L11

Added line #L11 was not covered by tests
{
#region "Preconfigured error codes"

Expand All @@ -19,19 +22,11 @@ public class JsConnectException : Exception
/// </summary>
public const string ERROR_INVALID_CLIENT = "invalid_client";

#endregion
#endregion

/// <summary>
/// Short error code.
/// </summary>
public string Error { get; set; }

/// <summary>
/// Default constructor.
/// </summary>
public JsConnectException(string error, string message) : base(message)
{
Error = error;
}
}
/// <summary>
/// Short error code.
/// </summary>
public string Error { get; set; } = error;

Check warning on line 30 in src/jsConnect/JsConnectException.cs

View check run for this annotation

Codecov / codecov/patch

src/jsConnect/JsConnectException.cs#L30

Added line #L30 was not covered by tests
}
}
2 changes: 1 addition & 1 deletion src/jsConnect/Models/JsConnectResponseModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public string Message
#region "User Data"

[JsonIgnore]
private readonly Dictionary<string, string> UserData = new();
private readonly Dictionary<string, string> UserData = [];

Check warning on line 51 in src/jsConnect/Models/JsConnectResponseModel.cs

View check run for this annotation

Codecov / codecov/patch

src/jsConnect/Models/JsConnectResponseModel.cs#L51

Added line #L51 was not covered by tests

[JsonProperty("uniqueid")]
public string UniqueId
Expand Down
2 changes: 1 addition & 1 deletion src/jsConnect/jsConnect.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<Description>Vanilla Forums' jsConnect for ASP.NET Core MVC</Description>
<Authors>Petr Svihlik;Jan Lenoch</Authors>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<AssemblyName>jsConnect</AssemblyName>
<PackageId>jsConnectAspNetCoreMvc</PackageId>
<PackageLicenseUrl>https://github.com/petrsvihlik/jsConnectAspNetCoreMvc/blob/master/LICENSE</PackageLicenseUrl>
Expand Down

0 comments on commit 065be0e

Please sign in to comment.