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

Remove System.Configuration.ConfigurationManager as NuGet dependency #1400

Merged
merged 1 commit into from
Aug 13, 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
4 changes: 0 additions & 4 deletions main/NPOI.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@
<PackageReference Include="SixLabors.ImageSharp" Version="2.1.8" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' != 'net472' ">
<PackageReference Include="System.Configuration.ConfigurationManager" Version="6.0.0" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net472' ">
<Reference Include="System.Configuration" />
</ItemGroup>
Expand Down
11 changes: 9 additions & 2 deletions main/Util/POILogFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,18 @@ public static POILogger GetLogger(String cat)
// that our users can set the system property
// between class loading and first use
if(_loggerClassName == null) {
#if NETFRAMEWORK
try {
_loggerClassName = ConfigurationManager.AppSettings["loggername"];
} catch(Exception) {}

// Use the default logger if none specified,
#endif
if(_loggerClassName == null)
{
// try environment
_loggerClassName = Environment.GetEnvironmentVariable("NPOI_LOGGER_NAME");
}

// Use the default logger if none specified,
// or none could be fetched
if(_loggerClassName == null) {
_loggerClassName = _nullLogger.GetType().Name;
Expand Down
13 changes: 11 additions & 2 deletions main/Util/SystemOutLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,18 @@ public override bool Check(int level)
int currentLevel;
try
{
string temp = ConfigurationManager.AppSettings["poi.log.level"];
if (string.IsNullOrEmpty(temp))
string temp = Environment.GetEnvironmentVariable("NPOI_LOG_LEVEL");
#if NETFRAMEWORK
if (temp == null)
{
temp = ConfigurationManager.AppSettings["poi.log.level"];
}
#endif
if(string.IsNullOrEmpty(temp))
{
temp = WARN.ToString(CultureInfo.InvariantCulture);
}

currentLevel = int.Parse(temp, CultureInfo.InvariantCulture);
}
catch
Expand Down
1 change: 1 addition & 0 deletions testcases/main/NPOI.TestCases.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="NUnit" Version="3.14.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="6.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Loading