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 TargetFramework to net8.0 #39

Merged
merged 2 commits into from
Aug 30, 2024
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
14 changes: 7 additions & 7 deletions ConfiguredSqlConnection/ConfiguredSqlConnection.csproj
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<UserSecretsId>5405e2de-7a05-4014-aea5-3ee845eb7fee</UserSecretsId>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<Title>ConfiguredSqlConnection</Title>
<Version>1.1.5</Version>
<Version>1.2.0</Version>
<Authors>Senia,ArdenHide,Lomet</Authors>
<Company>The-Poolz</Company>
<PackageProjectUrl>https://www.nuget.org/packages/ConfiguredSqlConnection</PackageProjectUrl>
Expand All @@ -17,7 +17,7 @@
<Description>The NuGet package is a collection of utilities for working with SQL Server database connections using environment settings and secure connection strings.</Description>
<RepositoryUrl>https://github.com/The-Poolz/ConfiguredSqlConnection</RepositoryUrl>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<PackageReleaseNotes>- Update packages version to newest.</PackageReleaseNotes>
<PackageReleaseNotes>https://github.com/The-Poolz/ConfiguredSqlConnection/releases/tag/v1.2.0</PackageReleaseNotes>
</PropertyGroup>

<ItemGroup>
Expand All @@ -32,12 +32,12 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="7.0.14" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.14" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="7.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="8.0.8" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.8" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="8.0.0" />
<PackageReference Include="SecretsManager" Version="1.0.0" />
<PackageReference Include="TestableDbContext.Mock" Version="1.0.0" />
<PackageReference Include="Utils.EnvironmentManager" Version="2.0.1" />
<PackageReference Include="Utils.EnvironmentManager" Version="4.0.1" />
</ItemGroup>

</Project>
4 changes: 2 additions & 2 deletions ConfiguredSqlConnection/Extensions/ConnectionStringFactory.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using SecretsManager;
using EnvironmentManager;
using System.ComponentModel;
using EnvironmentManager.Static;
using Microsoft.Extensions.Configuration;

namespace ConfiguredSqlConnection.Extensions;
Expand All @@ -17,7 +17,7 @@ public static string GetConnection(ContextOption option, string? dbName = null)

public static string GetConnectionFromSecret()
{
var secretValue = new EnvManager().GetEnvironmentValue<string>("CONFIGUREDSQLCONNECTION_SECRET_NAME_OF_CONNECTION", true);
var secretValue = EnvManager.Get<string>("CONFIGUREDSQLCONNECTION_SECRET_NAME_OF_CONNECTION", true);

return new SecretManager().GetSecretValue(secretValue, "connectionString");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
using EnvironmentManager;
using EnvironmentManager.Static;

namespace ConfiguredSqlConnection.Extensions;

public static class ConnectionStringFromEnvironmentFactory
{
private static readonly EnvManager envManager = new();
private static ContextOption DbMode =>
envManager.GetEnvironmentValue<ContextOption>("CONFIGUREDSQLCONNECTION_DB_MODE", true);
EnvManager.Get<ContextOption>("CONFIGUREDSQLCONNECTION_DB_MODE", true);
private static string DbName =>
envManager.GetEnvironmentValue<string>("CONFIGUREDSQLCONNECTION_DB_NAME");
EnvManager.Get<string>("CONFIGUREDSQLCONNECTION_DB_NAME");

public static string GetConnectionFromEnvironment() =>
ConnectionStringFactory.GetConnection(DbMode, DbName);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using EnvironmentManager;
using EnvironmentManager.Static;
using Microsoft.EntityFrameworkCore;

namespace ConfiguredSqlConnection.Extensions;
Expand All @@ -15,9 +15,8 @@ public DbContextEnvironmentFactory()
public DbContextEnvironmentFactory(DbContextOptionsBuilderFactory<TContext> optionsBuilderFactory)
: base(optionsBuilderFactory)
{
var envManager = new EnvManager();
dbMode = envManager.GetEnvironmentValue<ContextOption>("CONFIGUREDSQLCONNECTION_DB_MODE", true);
dbName = envManager.GetEnvironmentValue<string>("CONFIGUREDSQLCONNECTION_DB_NAME");
dbMode = EnvManager.Get<ContextOption>("CONFIGUREDSQLCONNECTION_DB_MODE", true);
dbName = EnvManager.Get<string>("CONFIGUREDSQLCONNECTION_DB_NAME");
}

public virtual TContext CreateFromEnvironment() =>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
using SecretsManager;
using EnvironmentManager;
using EnvironmentManager.Static;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;

namespace ConfiguredSqlConnection.Extensions;

public static class DbContextOptionsBuilderExtensions
{
private static readonly EnvManager envManager = new();

public static DbContextOptionsBuilder ConfigureFromActionConnection(this DbContextOptionsBuilder optionsBuilder, string? migrationsAssembly = null)
{
if (optionsBuilder.IsConfigured) return optionsBuilder;
var connectionString = envManager.GetEnvironmentValue<string>("CONFIGUREDSQLCONNECTION_ACTION_CONNECTION");
var connectionString = EnvManager.Get<string>("CONFIGUREDSQLCONNECTION_ACTION_CONNECTION");
if (string.IsNullOrEmpty(connectionString)) return optionsBuilder;

optionsBuilder.UseSqlServer(connectionString, ConfigureSqlServerOptionsAction(migrationsAssembly));
Expand All @@ -23,7 +21,7 @@ public static DbContextOptionsBuilder ConfigureFromActionConnection(this DbConte
public static DbContextOptionsBuilder ConfigureFromSecretConnection(this DbContextOptionsBuilder optionsBuilder, string? migrationsAssembly = null)
{
if (optionsBuilder.IsConfigured) return optionsBuilder;
var secretValue = envManager.GetEnvironmentValue<string>("CONFIGUREDSQLCONNECTION_SECRET_NAME_OF_CONNECTION", true);
var secretValue = EnvManager.Get<string>("CONFIGUREDSQLCONNECTION_SECRET_NAME_OF_CONNECTION", true);
var connectionString = new SecretManager().GetSecretValue(secretValue, "connectionString");
if (string.IsNullOrEmpty(connectionString)) return optionsBuilder;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void CreateFromEnvironment()
[Fact]
public void CreateFromEnvironment_OptionNotSet_ThrowException()
{
var expectedExceptionMessage = $"Environment variable 'CONFIGUREDSQLCONNECTION_DB_MODE' is null or empty.";
var expectedExceptionMessage = "Environment variable 'CONFIGUREDSQLCONNECTION_DB_MODE' is null or empty. (Parameter 'envValue')";
Environment.SetEnvironmentVariable("CONFIGUREDSQLCONNECTION_DB_MODE", $"");
Environment.SetEnvironmentVariable("CONFIGUREDSQLCONNECTION_DB_NAME", $"");
var factory = new Mock<DbContextEnvironmentFactory<DbContext>>(optionsBuilderFactory);
Expand Down
Loading