Skip to content

Commit

Permalink
Drop .NET 6
Browse files Browse the repository at this point in the history
  • Loading branch information
bkoelman committed Dec 24, 2024
1 parent 16c461d commit 209dbb7
Show file tree
Hide file tree
Showing 43 changed files with 202 additions and 258 deletions.
5 changes: 0 additions & 5 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,6 @@
<NoWarn>$(NoWarn);CA1062</NoWarn>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFramework)' == 'net6.0'">
<!-- Workaround for https://github.com/dotnet/runtime/issues/72263 -->
<NoWarn>$(NoWarn);SYSLIB1006</NoWarn>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="JetBrains.Annotations" Version="2024.2.*" PrivateAssets="All" />
<PackageReference Include="CSharpGuidelinesAnalyzer" Version="3.8.*" PrivateAssets="All" />
Expand Down
1 change: 1 addition & 0 deletions JsonApiDotNetCore.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ JsonApiDotNetCore.ArgumentGuard.NotNull($EXPR$);</s:String>
<s:Int64 x:Key="/Default/CodeEditing/NullCheckPatterns/PatternTypeNamesToPriority/=JetBrains_002EReSharper_002EFeature_002EServices_002ECSharp_002ENullChecking_002EThrowExpressionNullCheckPattern/@EntryIndexedValue">3000</s:Int64>
<s:Int64 x:Key="/Default/CodeEditing/NullCheckPatterns/PatternTypeNamesToPriority/=JetBrains_002EReSharper_002EFeature_002EServices_002ECSharp_002ENullChecking_002ETraceAssertPattern/@EntryIndexedValue">50</s:Int64>
<s:Boolean x:Key="/Default/CodeInspection/CodeAnnotations/PropagateAnnotations/@EntryValue">False</s:Boolean>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/GeneratedFilesAndFolders/=83FF097C_002DC8C6_002D477B_002D9FAB_002DDF99B84978B5_002Ff_003AReadOnlySet_002Ecs/@EntryIndexedValue">83FF097C-C8C6-477B-9FAB-DF99B84978B5/f:ReadOnlySet.cs</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/AnalysisEnabled/@EntryValue">SOLUTION</s:String>
<s:Boolean x:Key="/Default/CodeInspection/Highlighting/IdentifierHighlightingEnabled/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/Highlighting/IncludeWarningsInSwea/@EntryValue">True</s:Boolean>
Expand Down
8 changes: 2 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,9 @@ See also our [versioning policy](./VERSIONING_POLICY.md).
| | | 7 | 7 |
| | | 8 | 8, 9 |
| | | 9 | 9 |
| master | Preview | 6 | 6, 7 |
| | | 7 | 7 |
| | | 8 | 8, 9 |
| master | Preview | 8 | 8, 9 |
| | | 9 | 9 |
| openapi | Experimental | 6 | 6, 7 |
| | | 7 | 7 |
| | | 8 | 8, 9 |
| openapi | Experimental | 8 | 8, 9 |
| | | 9 | 9 |

## Contributing
Expand Down
15 changes: 1 addition & 14 deletions package-versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<GitHubActionsTestLoggerVersion>2.4.*</GitHubActionsTestLoggerVersion>
<InheritDocVersion>2.0.*</InheritDocVersion>
<SourceLinkVersion>8.0.*</SourceLinkVersion>
<SystemTextJsonVersion>9.0.*</SystemTextJsonVersion>
<TestSdkVersion>17.11.*</TestSdkVersion>
<XunitVersion>2.9.*</XunitVersion>
<XunitVisualStudioVersion>2.8.*</XunitVisualStudioVersion>
Expand All @@ -28,7 +29,6 @@
<AspNetCoreVersion>9.0.*</AspNetCoreVersion>
<EntityFrameworkCoreVersion>9.0.*</EntityFrameworkCoreVersion>
<EntityFrameworkCorePomeloVersion>9.0.0-*</EntityFrameworkCorePomeloVersion>
<SystemTextJsonVersion>$(AspNetCoreVersion)</SystemTextJsonVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFramework)' == 'net8.0'">
Expand All @@ -39,18 +39,5 @@
<AspNetCoreVersion>8.0.*</AspNetCoreVersion>
<EntityFrameworkCoreVersion>8.0.*</EntityFrameworkCoreVersion>
<EntityFrameworkCorePomeloVersion>$(EntityFrameworkCoreVersion)</EntityFrameworkCorePomeloVersion>
<SystemTextJsonVersion>$(AspNetCoreVersion)</SystemTextJsonVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFramework)' == 'net6.0'">
<!-- Published dependencies (only update on major version change) -->
<EntityFrameworkCoreFrozenVersion>6.0.0</EntityFrameworkCoreFrozenVersion>

<!-- Non-published dependencies (these are safe to update, won't cause a breaking change) -->
<AspNetCoreVersion>6.0.*</AspNetCoreVersion>
<DateOnlyTimeOnlyVersion>2.1.*</DateOnlyTimeOnlyVersion>
<EntityFrameworkCoreVersion>7.0.*</EntityFrameworkCoreVersion>
<EntityFrameworkCorePomeloVersion>$(EntityFrameworkCoreVersion)</EntityFrameworkCorePomeloVersion>
<SystemTextJsonVersion>8.0.*</SystemTextJsonVersion>
</PropertyGroup>
</Project>
2 changes: 1 addition & 1 deletion src/Examples/DapperExample/DapperExample.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFrameworks>net9.0;net8.0;net6.0</TargetFrameworks>
<TargetFrameworks>net9.0;net8.0</TargetFrameworks>
</PropertyGroup>

<Import Project="..\..\..\package-versions.props" />
Expand Down
6 changes: 3 additions & 3 deletions src/Examples/DapperExample/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@
}
case DatabaseProvider.MySql:
{
#if NET9_0_OR_GREATER
ServerVersion serverVersion = await ServerVersion.AutoDetectAsync(connectionString);
#else
#if NET8_0
ServerVersion serverVersion = ServerVersion.AutoDetect(connectionString);
#else
ServerVersion serverVersion = await ServerVersion.AutoDetectAsync(connectionString);
#endif

builder.Services.AddMySql<AppDbContext>(connectionString, serverVersion, optionsAction: options => SetDbContextDebugOptions(options));
Expand Down
3 changes: 0 additions & 3 deletions src/Examples/DapperExample/Repositories/ResultSetMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
using JsonApiDotNetCore.Queries.Expressions;
using JsonApiDotNetCore.Resources;
using JsonApiDotNetCore.Resources.Annotations;
#if NET6_0
using JsonApiDotNetCore;
#endif

namespace DapperExample.Repositories;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFrameworks>net9.0;net8.0;net6.0</TargetFrameworks>
<TargetFrameworks>net9.0;net8.0</TargetFrameworks>
</PropertyGroup>

<Import Project="..\..\..\package-versions.props" />
Expand Down
2 changes: 1 addition & 1 deletion src/Examples/GettingStarted/GettingStarted.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFrameworks>net9.0;net8.0;net6.0</TargetFrameworks>
<TargetFrameworks>net9.0;net8.0</TargetFrameworks>
</PropertyGroup>

<Import Project="..\..\..\package-versions.props" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,14 @@
using JsonApiDotNetCore.Queries.Expressions;
using JsonApiDotNetCore.Resources;
using JsonApiDotNetCoreExample.Models;
#if NET6_0
using Microsoft.AspNetCore.Authentication;
#endif

namespace JsonApiDotNetCoreExample.Definitions;

[UsedImplicitly(ImplicitUseKindFlags.InstantiatedNoFixedConstructorSignature)]
public sealed class TodoItemDefinition(
IResourceGraph resourceGraph,
#if NET6_0
ISystemClock systemClock
#else
TimeProvider timeProvider
#endif
)
public sealed class TodoItemDefinition(IResourceGraph resourceGraph, TimeProvider timeProvider)
: JsonApiResourceDefinition<TodoItem, long>(resourceGraph)
{
#if NET6_0
private readonly Func<DateTimeOffset> _getUtcNow = () => systemClock.UtcNow;
#else
private readonly Func<DateTimeOffset> _getUtcNow = timeProvider.GetUtcNow;
#endif

public override SortExpression OnApplySort(SortExpression? existingSort)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFrameworks>net9.0;net8.0;net6.0</TargetFrameworks>
<TargetFrameworks>net9.0;net8.0</TargetFrameworks>
</PropertyGroup>

<Import Project="..\..\..\package-versions.props" />
Expand Down
7 changes: 0 additions & 7 deletions src/Examples/JsonApiDotNetCoreExample/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Diagnostics;
using Microsoft.Extensions.DependencyInjection.Extensions;
#if NET6_0
using Microsoft.AspNetCore.Authentication;
#endif

[assembly: ExcludeFromCodeCoverage]

Expand Down Expand Up @@ -48,11 +45,7 @@ static void ConfigureServices(WebApplicationBuilder builder)
{
using IDisposable _ = CodeTimingSessionManager.Current.Measure("Configure services");

#if NET6_0
builder.Services.TryAddSingleton<ISystemClock, SystemClock>();
#else
builder.Services.TryAddSingleton(TimeProvider.System);
#endif

builder.Services.AddDbContext<AppDbContext>(options =>
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFrameworks>net9.0;net8.0;net6.0</TargetFrameworks>
<TargetFrameworks>net9.0;net8.0</TargetFrameworks>
</PropertyGroup>

<Import Project="..\..\..\package-versions.props" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFrameworks>net9.0;net8.0;net6.0</TargetFrameworks>
<TargetFrameworks>net9.0;net8.0</TargetFrameworks>
</PropertyGroup>

<Import Project="..\..\..\package-versions.props" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,7 @@ public Task<IReadOnlyCollection<TResource>> GetAsync(QueryLayer queryLayer, Canc
IEnumerable<TResource> dataSource = GetDataSource();
IEnumerable<TResource> resources = _queryLayerToLinqConverter.ApplyQueryLayer(queryLayer, dataSource);

#if NET6_0
return Task.FromResult<IReadOnlyCollection<TResource>>(Array.AsReadOnly(resources.ToArray()));
#else
return Task.FromResult<IReadOnlyCollection<TResource>>(resources.ToArray().AsReadOnly());
#endif
}

/// <inheritdoc />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,7 @@ public Task<IReadOnlyCollection<TResource>> GetAsync(CancellationToken cancellat
_paginationContext.IsPageFull = true;
}

#if NET6_0
return Task.FromResult<IReadOnlyCollection<TResource>>(Array.AsReadOnly(resources));
#else
return Task.FromResult<IReadOnlyCollection<TResource>>(resources.AsReadOnly());
#endif
}

private void LogFiltersInTopScope()
Expand Down
2 changes: 1 addition & 1 deletion src/Examples/ReportsExample/ReportsExample.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFrameworks>net9.0;net8.0;net6.0</TargetFrameworks>
<TargetFrameworks>net9.0;net8.0</TargetFrameworks>
</PropertyGroup>

<Import Project="..\..\..\package-versions.props" />
Expand Down
18 changes: 0 additions & 18 deletions src/JsonApiDotNetCore.Annotations/ArgumentGuard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,30 +30,12 @@ public static void NotNullNorEmpty<T>([SysNotNull] IEnumerable<T>? value, [Calle
[AssertionMethod]
public static void NotNullNorEmpty([SysNotNull] string? value, [CallerArgumentExpression(nameof(value))] string? parameterName = null)
{
#if !NET6_0
ArgumentException.ThrowIfNullOrEmpty(value, parameterName);
#else
ArgumentNullException.ThrowIfNull(value, parameterName);

if (value.Length == 0)
{
throw new ArgumentException("String cannot be null or empty.", parameterName);
}
#endif
}

[AssertionMethod]
public static void NotNullNorWhitespace([SysNotNull] string? value, [CallerArgumentExpression(nameof(value))] string? parameterName = null)
{
#if !NET6_0
ArgumentException.ThrowIfNullOrWhiteSpace(value, parameterName);
#else
ArgumentNullException.ThrowIfNull(value, parameterName);

if (string.IsNullOrWhiteSpace(value))
{
throw new ArgumentException("String cannot be null, empty, or whitespace.", parameterName);
}
#endif
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net8.0;net6.0;netstandard1.0</TargetFrameworks>
<TargetFrameworks>net8.0;netstandard1.0</TargetFrameworks>
<IsPackable>true</IsPackable>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<RootNamespace>JsonApiDotNetCore</RootNamespace>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
#if NET6_0
using System.Collections.ObjectModel;
#endif

#if NET6_0
#pragma warning disable AV1130 // Return type in method signature should be an interface to an unchangeable collection
#endif

namespace JsonApiDotNetCore;

Expand All @@ -13,22 +7,6 @@ internal static class PolyfillCollectionExtensions
{
public static IReadOnlySet<T> AsReadOnly<T>(this HashSet<T> source)
{
// We can't use ReadOnlySet<T> yet, which is being introduced in .NET 9.
return source;
}

#if NET6_0
public static ReadOnlyDictionary<TKey, TValue> AsReadOnly<TKey, TValue>(this IDictionary<TKey, TValue> source)
where TKey : notnull
{
// The AsReadOnly() extension method is unavailable in .NET 6.
return new ReadOnlyDictionary<TKey, TValue>(source);
}

public static ReadOnlyCollection<T> AsReadOnly<T>(this T[] source)
{
// The AsReadOnly() extension method is unavailable in .NET 6.
return Array.AsReadOnly(source);
return new ReadOnlySet<T>(source);
}
#endif
}
Loading

0 comments on commit 209dbb7

Please sign in to comment.