Skip to content

Commit

Permalink
Remove System.Configuration.ConfigurationManager package reference
Browse files Browse the repository at this point in the history
  • Loading branch information
lahma committed Aug 10, 2024
1 parent 06545bc commit c692436
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 32 deletions.
16 changes: 16 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,22 @@

[http://www.quartz-scheduler.net](http://www.quartz-scheduler.net)

## Release 3.13.0, XXX x 2024

This release removes aims to modernise targeted platforms and used dependencies.

The `System.Configuration.ConfigurationManager` reference from non-framework builds. This means
using App.config's `<quartz>` section as Quartz configuration source is only supported on .NET Framework builds. This
change was made to reduce legacy dependencies and to make Quartz more compatible with modern .NET.

The `netcoreapp3.1` target has been removed from DI and hosting integration package which makes NET 6 the lowest supported
modern runtime version for those packages.

* CHANGES
* Remove System.Configuration.ConfigurationManager package reference (#2513)
* Remove netcoreapp3.1 support and trim dependencies (#2507)


## Release 3.12.0, Aug 3 2024

This release aims to alleviate some problems that have been present then Quartz's own global singletons clash
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ protected override IDbConnectionManager GetDBConnectionManager()
return serviceProvider.GetRequiredService<IDbConnectionManager>();
}

private protected override string GetNamedConnectionString(string connectionStringName)
protected override string? GetNamedConnectionString(string connectionStringName)
{
var configuration = serviceProvider.GetRequiredService<IConfiguration>();
var connectionString = configuration.GetConnectionString(connectionStringName);
Expand Down
30 changes: 25 additions & 5 deletions src/Quartz/Impl/StdSchedulerFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Configuration;
using System.IO;
using System.Reflection;
using System.Threading;
Expand Down Expand Up @@ -265,7 +264,7 @@ public virtual void Initialize()

internal static NameValueCollection? InitializeProperties(ILog logger, bool throwOnProblem)
{
var props = Util.Configuration.GetSection(ConfigurationSectionName);
var props = ReadConfigurationSection();
var requestedFile = QuartzEnvironment.GetEnvironmentVariable(PropertiesFile);
var propFileName = !string.IsNullOrWhiteSpace(requestedFile) ? requestedFile : "~/quartz.config";

Expand Down Expand Up @@ -313,6 +312,23 @@ public virtual void Initialize()
return props;
}

private static NameValueCollection? ReadConfigurationSection()
{
#if NETFRAMEWORK
try
{
return (NameValueCollection) System.Configuration.ConfigurationManager.GetSection(ConfigurationSectionName);
}
catch (Exception e)
{
var log = LogProvider.GetLogger(typeof(StdSchedulerFactory));
log.Warn($"Could not read configuration using ConfigurationManager.GetSection: {e.Message}");
}
#endif
return null;

}

/// <summary>
/// Creates a new name value collection and overrides its values
/// with system values (environment variables).
Expand Down Expand Up @@ -820,7 +836,7 @@ private async Task<IScheduler> Instantiate()
ISchedulerPlugin plugin;
try
{
var pluginTypeType = loadHelper.LoadType(plugInType) ?? throw new ConfigurationException($"Could not load plugin type {plugInType}");
var pluginTypeType = loadHelper.LoadType(plugInType) ?? throw new SchedulerException($"Could not load plugin type {plugInType}");
// we need to use concrete types to resolve correct one
var method = GetType().GetMethod(nameof(InstantiateType), BindingFlags.Instance | BindingFlags.NonPublic)!.MakeGenericMethod(pluginTypeType);
plugin = (ISchedulerPlugin) method.Invoke(this, new [] { pluginTypeType })!;
Expand Down Expand Up @@ -1090,10 +1106,14 @@ private async Task<IScheduler> Instantiate()
}
}

private protected virtual string GetNamedConnectionString(string dsConnectionStringName)
protected virtual string? GetNamedConnectionString(string connectionStringName)
{
var connectionStringSettings = ConfigurationManager.ConnectionStrings[dsConnectionStringName];
#if NETFRAMEWORK
var connectionStringSettings = System.Configuration.ConfigurationManager.ConnectionStrings[connectionStringName];
return connectionStringSettings.ConnectionString;
#else
return null;
#endif
}

protected virtual T InstantiateType<T>(Type? implementationType)
Expand Down
1 change: 0 additions & 1 deletion src/Quartz/Quartz.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
<PackageReference Include="LibLog" Version="5.0.8" PrivateAssets="all" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="2.1.1" />
<PackageReference Include="PolySharp" Version="1.14.1" PrivateAssets="all" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="6.0.1" Condition=" '$(TargetFramework)' != 'net462' and '$(TargetFramework)' != 'net472' " />
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="4.7.1" Condition=" '$(TargetFramework)' == 'netstandard2.0' or '$(TargetFramework)' == 'net472' " />
</ItemGroup>
</Project>
25 changes: 0 additions & 25 deletions src/Quartz/Util/Configuration.cs

This file was deleted.

0 comments on commit c692436

Please sign in to comment.