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

net8 #19

Merged
merged 1 commit into from
Feb 24, 2024
Merged

net8 #19

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 .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 @@
/// <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 @@
/// 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 @@

#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 @@ -8,7 +8,7 @@

namespace jsConnect
{
public static class Extensions

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

View workflow job for this annotation

GitHub Actions / build

Missing XML comment for publicly visible type or member 'Extensions'

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

View workflow job for this annotation

GitHub Actions / build

Missing XML comment for publicly visible type or member 'Extensions'

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

View workflow job for this annotation

GitHub Actions / build

Missing XML comment for publicly visible type or member 'Extensions'
{
/// <summary>
/// Converts given object to JSON with padding.
Expand All @@ -22,11 +22,8 @@
{
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 @@
/// <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 @@ -81,16 +72,13 @@
}

/// <summary>
/// Retrieves an object from a given <see cref="Dictionary{TKey,TValue}"/>. Covers situations where the <see cref="key"/> doesn't exist.

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

View workflow job for this annotation

GitHub Actions / build

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

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

View workflow job for this annotation

GitHub Actions / build

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

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

View workflow job for this annotation

GitHub Actions / build

XML comment has cref attribute 'key' that could not be resolved
/// </summary>
/// <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 @@
/// </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 @@ -4,26 +4,26 @@

namespace jsConnect.Models
{
public class JsConnectResponseModel

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

View workflow job for this annotation

GitHub Actions / build

Missing XML comment for publicly visible type or member 'JsConnectResponseModel'

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

View workflow job for this annotation

GitHub Actions / build

Missing XML comment for publicly visible type or member 'JsConnectResponseModel'

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

View workflow job for this annotation

GitHub Actions / build

Missing XML comment for publicly visible type or member 'JsConnectResponseModel'
{
private string _error = null;
private string _message = null;

[JsonProperty("client_id")]
public string ClientId

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

View workflow job for this annotation

GitHub Actions / build

Missing XML comment for publicly visible type or member 'JsConnectResponseModel.ClientId'

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

View workflow job for this annotation

GitHub Actions / build

Missing XML comment for publicly visible type or member 'JsConnectResponseModel.ClientId'

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

View workflow job for this annotation

GitHub Actions / build

Missing XML comment for publicly visible type or member 'JsConnectResponseModel.ClientId'
{
get; set;
}

[JsonProperty("signature")]
public string Signature

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

View workflow job for this annotation

GitHub Actions / build

Missing XML comment for publicly visible type or member 'JsConnectResponseModel.Signature'

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

View workflow job for this annotation

GitHub Actions / build

Missing XML comment for publicly visible type or member 'JsConnectResponseModel.Signature'

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

View workflow job for this annotation

GitHub Actions / build

Missing XML comment for publicly visible type or member 'JsConnectResponseModel.Signature'
{
get; set;
}


[JsonProperty("error")]
public string Error

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

View workflow job for this annotation

GitHub Actions / build

Missing XML comment for publicly visible type or member 'JsConnectResponseModel.Error'

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

View workflow job for this annotation

GitHub Actions / build

Missing XML comment for publicly visible type or member 'JsConnectResponseModel.Error'

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

View workflow job for this annotation

GitHub Actions / build

Missing XML comment for publicly visible type or member 'JsConnectResponseModel.Error'
{
get { return _error; }
set
Expand All @@ -48,7 +48,7 @@
#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
Loading