Skip to content

Commit

Permalink
Deprecate Newtonsoft.Json. (#49)
Browse files Browse the repository at this point in the history
  • Loading branch information
chullybun committed Jan 6, 2024
1 parent 332b360 commit e450b7c
Show file tree
Hide file tree
Showing 20 changed files with 187 additions and 106 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

Represents the **NuGet** versions.

## v2.3.15
- *Fixed:* Updated `CoreEx` to version `3.8.0`.
- *Fixed:* Updated `OnRamp` to version `2.0.0` which necessitated internal change from `Newtonsoft.Json` (now deprecated) to `System.Text.Json`; additionally, the `DataParser` was refactored accordingly.

## v2.3.14
- *Fixed:* All related package dependencies updated to latest.

Expand Down
2 changes: 1 addition & 1 deletion Common.targets
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<Version>2.3.14</Version>
<Version>2.3.15</Version>
<LangVersion>preview</LangVersion>
<Authors>Avanade</Authors>
<Company>Avanade</Company>
Expand Down
2 changes: 1 addition & 1 deletion src/DbEx.MySql/DbEx.MySql.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="CoreEx.Database.MySql" Version="3.6.3" />
<PackageReference Include="CoreEx.Database.MySql" Version="3.8.0" />
<PackageReference Include="dbup-mysql" Version="5.0.37" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion src/DbEx.SqlServer/DbEx.SqlServer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="CoreEx.Database.SqlServer" Version="3.6.3" />
<PackageReference Include="CoreEx.Database.SqlServer" Version="3.8.0" />
<PackageReference Include="dbup-sqlserver" Version="5.0.37" />
</ItemGroup>

Expand Down
9 changes: 5 additions & 4 deletions src/DbEx/Console/MigrationConsoleBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ namespace DbEx.Console
/// <para>The underlying command line parsing is provided by <see href="https://natemcmaster.github.io/CommandLineUtils/"/>.</para></remarks>
public abstract class MigrationConsoleBase
{
private static readonly string[] memberNames = ["args"];
private const string EntryAssemblyOnlyOptionName = "entry-assembly-only";
private const string AcceptPromptsOptionName = "accept-prompts";
private CommandArgument<MigrationCommand>? _commandArg;
Expand Down Expand Up @@ -62,7 +63,7 @@ public abstract class MigrationConsoleBase
/// <summary>
/// Gets the console (command line) options.
/// </summary>
protected Dictionary<string, CommandOption?> ConsoleOptions { get; } = new();
protected Dictionary<string, CommandOption?> ConsoleOptions { get; } = [];

/// <summary>
/// Indicates whether to bypass standard execution of <see cref="OnWriteMasthead"/>, <see cref="OnWriteHeader"/>, <see cref="OnWriteArgs(DatabaseMigrationBase)"/> and <see cref="OnWriteFooter(double)"/>.
Expand Down Expand Up @@ -161,7 +162,7 @@ public async Task<int> RunAsync(string[] args, CancellationToken cancellationTok
return vr;
if (_additionalArgs.Values.Count > 0 && !(Args.MigrationCommand.HasFlag(MigrationCommand.CodeGen) || Args.MigrationCommand.HasFlag(MigrationCommand.Script) || Args.MigrationCommand.HasFlag(MigrationCommand.Execute)))
return new ValidationResult($"Additional arguments can only be specified when the command is '{nameof(MigrationCommand.CodeGen)}', '{nameof(MigrationCommand.Script)}' or '{nameof(MigrationCommand.Execute)}'.", new string[] { "args" });
return new ValidationResult($"Additional arguments can only be specified when the command is '{nameof(MigrationCommand.CodeGen)}', '{nameof(MigrationCommand.Script)}' or '{nameof(MigrationCommand.Execute)}'.", memberNames);
if (Args.MigrationCommand.HasFlag(MigrationCommand.CodeGen) || Args.MigrationCommand.HasFlag(MigrationCommand.Script))
{
Expand All @@ -178,7 +179,7 @@ public async Task<int> RunAsync(string[] args, CancellationToken cancellationTok
if (string.IsNullOrEmpty(_additionalArgs.Values[i]))
continue;
Args.ExecuteStatements ??= new List<string>();
Args.ExecuteStatements ??= [];
Args.ExecuteStatements.Add(_additionalArgs.Values[i]!);
}
}
Expand Down Expand Up @@ -404,7 +405,7 @@ public static void WriteStandardizedArgs(DatabaseMigrationBase migrator, Action<

migrator.Args.Logger.LogInformation("{Content}", $"Command = {migrator.Args.MigrationCommand}");
migrator.Args.Logger.LogInformation("{Content}", $"Provider = {migrator.Provider}");
migrator.Args.Logger.LogInformation("{Content}", $"SchemaOrder = {string.Join(", ", migrator.Args.SchemaOrder.ToArray())}");
migrator.Args.Logger.LogInformation("{Content}", $"SchemaOrder = {string.Join(", ", [.. migrator.Args.SchemaOrder])}");
migrator.Args.Logger.LogInformation("{Content}", $"OutDir = {migrator.Args.OutputDirectory?.FullName}");

additional?.Invoke(migrator.Args.Logger);
Expand Down
2 changes: 1 addition & 1 deletion src/DbEx/Console/MigrationConsoleBaseT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public TSelf Assemblies(params Type[] types)
list.Add(t.Assembly);
}

Args.AddAssembly(list.ToArray());
Args.AddAssembly([.. list]);
return (TSelf)this;
}

Expand Down
4 changes: 2 additions & 2 deletions src/DbEx/DatabaseExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public static async Task<List<DbTableSchema>> SelectSchemaAsync(this IDatabase d
var refDataPredicate = new Func<DbTableSchema, bool>(t => t.Columns.Any(c => c.Name == refDataCodeColumn && !c.IsPrimaryKey && c.DotNetType == "string") && t.Columns.Any(c => c.Name == refDataTextColumn && !c.IsPrimaryKey && c.DotNetType == "string"));

// Get all the tables and their columns.
using var sr = DatabaseMigrationBase.GetRequiredResourcesStreamReader("SelectTableAndColumns.sql", new Assembly[] { typeof(DatabaseExtensions).Assembly });
using var sr = DatabaseMigrationBase.GetRequiredResourcesStreamReader("SelectTableAndColumns.sql", [typeof(DatabaseExtensions).Assembly]);
#if NET7_0_OR_GREATER
await database.SqlStatement(await sr.ReadToEndAsync(cancellationToken).ConfigureAwait(false)).SelectQueryAsync(dr =>
#else
Expand Down Expand Up @@ -84,7 +84,7 @@ public static async Task<List<DbTableSchema>> SelectSchemaAsync(this IDatabase d
}

// Configure all the single column primary and unique constraints.
using var sr2 = DatabaseMigrationBase.GetRequiredResourcesStreamReader("SelectTablePrimaryKey.sql", new Assembly[] { typeof(DatabaseExtensions).Assembly });
using var sr2 = DatabaseMigrationBase.GetRequiredResourcesStreamReader("SelectTablePrimaryKey.sql", [typeof(DatabaseExtensions).Assembly]);
#if NET7_0_OR_GREATER
var pks = await database.SqlStatement(await sr2.ReadToEndAsync(cancellationToken).ConfigureAwait(false)).SelectQueryAsync(dr => new
#else
Expand Down
4 changes: 2 additions & 2 deletions src/DbEx/DbEx.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="CoreEx.Database" Version="3.6.3" />
<PackageReference Include="OnRamp" Version="1.0.8" />
<PackageReference Include="CoreEx.Database" Version="3.8.0" />
<PackageReference Include="OnRamp" Version="2.0.0" />
</ItemGroup>

<Import Project="..\..\Common.targets" />
Expand Down
6 changes: 3 additions & 3 deletions src/DbEx/DbSchema/DbTableSchema.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,17 +176,17 @@ public DbTableSchema(DbTableSchema table)
/// <summary>
/// Gets or sets the <see cref="DbColumnSchema"/> list.
/// </summary>
public List<DbColumnSchema> Columns { get; private set; } = new List<DbColumnSchema>();
public List<DbColumnSchema> Columns { get; private set; } = [];

/// <summary>
/// Gets the primary key <see cref="DbColumnSchema"/> list.
/// </summary>
public List<DbColumnSchema> PrimaryKeyColumns => Columns?.Where(x => x.IsPrimaryKey).ToList() ?? new List<DbColumnSchema>();
public List<DbColumnSchema> PrimaryKeyColumns => Columns?.Where(x => x.IsPrimaryKey).ToList() ?? [];

/// <summary>
/// Gets the standard <see cref="DbColumnSchema"/> list (i.e. not primary key, not created audit, not updated audit, not tenant-id, not row-version, not is-deleted).
/// </summary>
public List<DbColumnSchema> StandardColumns => Columns?.Where(x => !x.IsPrimaryKey && !x.IsCreatedAudit && !x.IsUpdatedAudit && !x.IsTenantId && !x.IsRowVersion && !x.IsIsDeleted).ToList() ?? new List<DbColumnSchema>();
public List<DbColumnSchema> StandardColumns => Columns?.Where(x => !x.IsPrimaryKey && !x.IsCreatedAudit && !x.IsUpdatedAudit && !x.IsTenantId && !x.IsRowVersion && !x.IsIsDeleted).ToList() ?? [];

/// <summary>
/// Gets the tenant idenfifier <see cref="DbColumnSchema"/> (if any).
Expand Down
7 changes: 6 additions & 1 deletion src/DbEx/Migration/Data/DataConfig.cs
Original file line number Diff line number Diff line change
@@ -1,25 +1,30 @@
// Copyright (c) Avanade. Licensed under the MIT License. See https://github.com/Avanade/DbEx

using System.Text.Json.Serialization;

namespace DbEx.Migration.Data
{
/// <summary>
/// Respresents the data configuration.
/// Represents the data configuration.
/// </summary>
public class DataConfig
{
/// <summary>
/// Gets or sets the pre-condition SQL.
/// </summary>
[JsonPropertyName("preConditionSql")]
public string? PreConditionSql { get; set; }

/// <summary>
/// Gets or sets the pre-SQL.
/// </summary>
[JsonPropertyName("preSql")]
public string? PreSql { get; set; }

/// <summary>
/// Gets or sets the post-SQL.
/// </summary>
[JsonPropertyName("postSql")]
public string? PostSql { get; set; }
}
}
Loading

0 comments on commit e450b7c

Please sign in to comment.