Skip to content

Commit b4ed61b

Browse files
committed
Code cleanup
1 parent 19f2a4a commit b4ed61b

20 files changed

+54
-264
lines changed

.gitignore

Lines changed: 3 additions & 201 deletions
Original file line numberDiff line numberDiff line change
@@ -1,203 +1,5 @@
1-
## Ignore Visual Studio temporary files, build results, and
2-
## files generated by popular Visual Studio add-ons.
3-
4-
# User-specific files
5-
*.suo
6-
*.user
7-
*.userosscache
8-
*.sln.docstates
9-
10-
# User-specific files (MonoDevelop/Xamarin Studio)
11-
*.userprefs
12-
13-
# Build results
14-
[Dd]ebug/
15-
[Dd]ebugPublic/
16-
[Rr]elease/
17-
[Rr]eleases/
18-
x64/
19-
x86/
20-
build/
21-
bld/
22-
[Bb]in/
23-
[Oo]bj/
24-
25-
# Visual Studo 2015 cache/options directory
261
.vs/
27-
28-
# JetBrains project files
29-
.idea/
30-
31-
# MSTest test Results
32-
[Tt]est[Rr]esult*/
33-
[Bb]uild[Ll]og.*
34-
35-
# NUNIT
36-
*.VisualState.xml
37-
TestResult.xml
38-
39-
# Build Results of an ATL Project
40-
[Dd]ebugPS/
41-
[Rr]eleasePS/
42-
dlldata.c
43-
44-
*_i.c
45-
*_p.c
46-
*_i.h
47-
*.ilk
48-
*.meta
49-
*.obj
50-
*.pch
51-
*.pdb
52-
*.pgc
53-
*.pgd
54-
*.rsp
55-
*.sbr
56-
*.tlb
57-
*.tli
58-
*.tlh
59-
*.tmp
60-
*.tmp_proj
61-
*.log
62-
*.vspscc
63-
*.vssscc
64-
.builds
65-
*.pidb
66-
*.svclog
67-
*.scc
68-
69-
# Chutzpah Test files
70-
_Chutzpah*
71-
72-
# Visual C++ cache files
73-
ipch/
74-
*.aps
75-
*.ncb
76-
*.opensdf
77-
*.sdf
78-
*.cachefile
79-
80-
# Visual Studio profiler
81-
*.psess
82-
*.vsp
83-
*.vspx
84-
85-
# TFS 2012 Local Workspace
86-
$tf/
87-
88-
# Guidance Automation Toolkit
89-
*.gpState
90-
91-
# ReSharper is a .NET coding add-in
92-
_ReSharper*/
93-
*.[Rr]e[Ss]harper
94-
*.DotSettings.user
95-
96-
# JustCode is a .NET coding addin-in
97-
.JustCode
98-
99-
# TeamCity is a build add-in
100-
_TeamCity*
101-
102-
# DotCover is a Code Coverage Tool
103-
*.dotCover
104-
105-
# NCrunch
106-
_NCrunch_*
107-
.*crunch*.local.xml
108-
109-
# MightyMoose
110-
*.mm.*
111-
AutoTest.Net/
112-
113-
# Web workbench (sass)
114-
.sass-cache/
115-
116-
# Installshield output folder
117-
[Ee]xpress/
118-
119-
# DocProject is a documentation generator add-in
120-
DocProject/buildhelp/
121-
DocProject/Help/*.HxT
122-
DocProject/Help/*.HxC
123-
DocProject/Help/*.hhc
124-
DocProject/Help/*.hhk
125-
DocProject/Help/*.hhp
126-
DocProject/Help/Html2
127-
DocProject/Help/html
128-
129-
# Click-Once directory
130-
publish/
131-
132-
# Publish Web Output
133-
*.[Pp]ublish.xml
134-
*.azurePubxml
135-
# TODO: Comment the next line if you want to checkin your web deploy settings
136-
# but database connection strings (with potential passwords) will be unencrypted
137-
*.pubxml
138-
*.publishproj
139-
140-
# NuGet Packages
141-
*.nupkg
142-
# The packages folder can be ignored because of Package Restore
143-
**/packages/*
144-
# except build/, which is used as an MSBuild target.
145-
!**/packages/build/
146-
# Uncomment if necessary however generally it will be regenerated when needed
147-
#!**/packages/repositories.config
148-
149-
# Windows Azure Build Output
150-
csx/
151-
*.build.csdef
152-
153-
# Windows Store app package directory
154-
AppPackages/
155-
156-
# Others
157-
*.[Cc]ache
158-
ClientBin/
159-
[Ss]tyle[Cc]op.*
160-
~$*
161-
*~
162-
*.dbmdl
163-
*.dbproj.schemaview
164-
*.pfx
165-
*.publishsettings
166-
node_modules/
167-
bower_components/
168-
169-
# RIA/Silverlight projects
170-
Generated_Code/
171-
172-
# Backup & report files from converting an old project file
173-
# to a newer Visual Studio version. Backup files are not needed,
174-
# because we have git ;-)
175-
_UpgradeReport_Files/
176-
Backup*/
177-
UpgradeLog*.XML
178-
UpgradeLog*.htm
179-
180-
# SQL Server files
181-
*.mdf
182-
*.ldf
183-
184-
# Business Intelligence projects
185-
*.rdl.data
186-
*.bim.layout
187-
*.bim_*.settings
188-
189-
# Microsoft Fakes
190-
FakesAssemblies/
191-
192-
# Node.js Tools for Visual Studio
193-
.ntvs_analysis.dat
194-
195-
# Visual Studio 6 build log
196-
*.plg
197-
198-
# Visual Studio 6 workspace options file
199-
*.opt
200-
201-
project.lock.json
202-
2+
bin/
3+
obj/
4+
test/
2035
artifacts/

sample/Sample/Sample.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@
1616
<ItemGroup>
1717
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
1818
<PackageReference Include="Serilog.Sinks.Async" Version="1.5.0" />
19-
<PackageReference Include="Serilog.Sinks.Console" Version="5.0.0" />
19+
<PackageReference Include="Serilog.Sinks.Console" Version="5.0.1" />
2020
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
2121
<PackageReference Include="Serilog.Enrichers.Environment" Version="2.3.0" />
2222
<PackageReference Include="Serilog.Expressions" Version="4.0.0" />
2323
<PackageReference Include="Serilog.Formatting.Compact" Version="2.0.0" />
2424
<PackageReference Include="Serilog.Enrichers.Thread" Version="3.1.0" />
25-
<PackageReference Include="PolySharp" Version="1.13.2" PrivateAssets="all" />
25+
<PackageReference Include="PolySharp" Version="1.14.1" PrivateAssets="all" />
2626
</ItemGroup>
2727

2828
<ItemGroup>

src/Serilog.Settings.Configuration/Serilog.Settings.Configuration.csproj

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
the target version. -->
1010
<TargetFrameworks>net462;netstandard2.0;net6.0;net7.0;net8.0</TargetFrameworks>
1111
<GenerateDocumentationFile>true</GenerateDocumentationFile>
12-
<AssemblyName>Serilog.Settings.Configuration</AssemblyName>
1312
<PackageTags>serilog;json</PackageTags>
1413
<PackageIcon>icon.png</PackageIcon>
1514
<PackageReadmeFile>README.md</PackageReadmeFile>
@@ -24,12 +23,8 @@
2423
</PropertyGroup>
2524

2625
<ItemGroup>
27-
<Using Remove="System.Net.Http" />
28-
</ItemGroup>
29-
30-
<ItemGroup>
31-
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
32-
<PackageReference Include="PolySharp" Version="1.13.2" PrivateAssets="All" />
26+
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
27+
<PackageReference Include="PolySharp" Version="1.14.1" PrivateAssets="All" />
3328
<PackageReference Include="Serilog" Version="3.1.1" />
3429
<None Include="..\..\assets\icon.png" Pack="true" PackagePath="" Visible="false" />
3530
<None Include="..\..\README.md" Pack="true" PackagePath="" />

src/Serilog.Settings.Configuration/Settings/Configuration/ConfigurationReader.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class ConfigurationReader : IConfigurationReader
1818
const string LevelSwitchNameRegex = @"^\${0,1}[A-Za-z]+[A-Za-z0-9]*$";
1919

2020
// Section names that can be handled by Serilog itself (hence builtin) without requiring any additional assemblies.
21-
static readonly string[] BuiltinSectionNames = { "LevelSwitches", "MinimumLevel", "Properties" };
21+
static readonly string[] BuiltinSectionNames = ["LevelSwitches", "MinimumLevel", "Properties"];
2222

2323
readonly IConfiguration _section;
2424
readonly IReadOnlyCollection<Assembly> _configurationAssemblies;
@@ -218,7 +218,7 @@ void ApplyMinimumLevelConfiguration(IConfigurationSection directive, Action<Logg
218218
}
219219
}
220220

221-
void SubscribeToLoggingLevelChanges(IConfigurationSection levelSection, LoggingLevelSwitch levelSwitch)
221+
static void SubscribeToLoggingLevelChanges(IConfigurationSection levelSection, LoggingLevelSwitch levelSwitch)
222222
{
223223
ChangeToken.OnChange(
224224
levelSection.GetReloadToken,

src/Serilog.Settings.Configuration/Settings/Configuration/ObjectArgumentValue.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ bool TryCreateContainer([NotNullWhen(true)] out object? result)
9191
{
9292
var argumentValue = ConfigurationReader.GetArgumentValue(configurationElements[i], _configurationAssemblies);
9393
var value = argumentValue.ConvertTo(elementType, resolutionContext);
94-
addMethod.Invoke(result, new[] { value });
94+
addMethod.Invoke(result, [value]);
9595
}
9696

9797
return true;

src/Serilog.Settings.Configuration/Settings/Configuration/ResolutionContext.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public void AddFilterSwitch(string filterSwitchName, LoggingFilterSwitchProxy fi
7070
_declaredFilterSwitches[referenceName] = filterSwitch;
7171
}
7272

73-
string ToSwitchReference(string switchName)
73+
static string ToSwitchReference(string switchName)
7474
{
7575
return switchName.StartsWith("$") ? switchName : $"${switchName}";
7676
}

test/Serilog.Settings.Configuration.Tests/ApiApprovalTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#if NET7_0
1+
#if NET8_0
22

33
using PublicApiGenerator;
44
using Shouldly;
@@ -15,7 +15,7 @@ public void PublicApi_Should_Not_Change_Unintentionally()
1515
new()
1616
{
1717
IncludeAssemblyAttributes = false,
18-
ExcludeAttributes = new[] { "System.Diagnostics.DebuggerDisplayAttribute" },
18+
ExcludeAttributes = ["System.Diagnostics.DebuggerDisplayAttribute"],
1919
});
2020

2121
publicApi.ShouldMatchApproved(options => options.WithFilenameGenerator((_, _, fileType, fileExtension) => $"{assembly.GetName().Name!}.{fileType}.{fileExtension}"));

test/Serilog.Settings.Configuration.Tests/ConfigurationReaderTests.cs

Lines changed: 26 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -185,17 +185,17 @@ public void MethodsAreSelectedBasedOnCountOfMatchedArgumentsAndThenStringType()
185185
Assert.Equal(typeof(string), selected?.GetParameters()[2].ParameterType);
186186
}
187187

188-
public static IEnumerable<object[]> FlatMinimumLevel => new List<object[]>
189-
{
190-
new object[] { GetConfigRoot(appsettingsJsonLevel: minimumLevelFlatTemplate.Format(LogEventLevel.Error)), LogEventLevel.Error },
191-
new object[] { GetConfigRoot(appsettingsDevelopmentJsonLevel: minimumLevelFlatTemplate.Format(LogEventLevel.Error)), LogEventLevel.Error },
192-
new object[] { GetConfigRoot(envVariables: new Dictionary<string, string?> {{minimumLevelFlatKey, LogEventLevel.Error.ToString()}}), LogEventLevel.Error},
193-
new object[] { GetConfigRoot(
188+
public static IEnumerable<object[]> FlatMinimumLevel =>
189+
[
190+
[GetConfigRoot(appsettingsJsonLevel: minimumLevelFlatTemplate.Format(LogEventLevel.Error)), LogEventLevel.Error],
191+
[GetConfigRoot(appsettingsDevelopmentJsonLevel: minimumLevelFlatTemplate.Format(LogEventLevel.Error)), LogEventLevel.Error],
192+
[GetConfigRoot(envVariables: new Dictionary<string, string?> {{minimumLevelFlatKey, LogEventLevel.Error.ToString()}}), LogEventLevel.Error],
193+
[GetConfigRoot(
194194
appsettingsJsonLevel: minimumLevelFlatTemplate.Format(LogEventLevel.Debug),
195195
envVariables: new Dictionary<string, string?> {{minimumLevelFlatKey, LogEventLevel.Error.ToString()}}),
196196
LogEventLevel.Error
197-
}
198-
};
197+
]
198+
];
199199

200200
[Theory]
201201
[MemberData(nameof(FlatMinimumLevel))]
@@ -209,17 +209,17 @@ public void FlatMinimumLevelCorrectOneIsEnabledOnLogger(IConfigurationRoot root,
209209
AssertLogEventLevels(loggerConfig, expectedMinimumLevel);
210210
}
211211

212-
public static IEnumerable<object[]> ObjectMinimumLevel => new List<object[]>
213-
{
214-
new object[] { GetConfigRoot(appsettingsJsonLevel: minimumLevelObjectTemplate.Format(LogEventLevel.Error)), LogEventLevel.Error },
215-
new object[] { GetConfigRoot(appsettingsJsonLevel: minimumLevelObjectTemplate.Format(LogEventLevel.Error.ToString().ToUpper())), LogEventLevel.Error },
216-
new object[] { GetConfigRoot(appsettingsDevelopmentJsonLevel: minimumLevelObjectTemplate.Format(LogEventLevel.Error)), LogEventLevel.Error },
217-
new object[] { GetConfigRoot(envVariables: new Dictionary<string, string?>{{minimumLevelObjectKey, LogEventLevel.Error.ToString() } }), LogEventLevel.Error },
218-
new object[] { GetConfigRoot(
212+
public static IEnumerable<object[]> ObjectMinimumLevel =>
213+
[
214+
[GetConfigRoot(appsettingsJsonLevel: minimumLevelObjectTemplate.Format(LogEventLevel.Error)), LogEventLevel.Error],
215+
[GetConfigRoot(appsettingsJsonLevel: minimumLevelObjectTemplate.Format(LogEventLevel.Error.ToString().ToUpper())), LogEventLevel.Error],
216+
[GetConfigRoot(appsettingsDevelopmentJsonLevel: minimumLevelObjectTemplate.Format(LogEventLevel.Error)), LogEventLevel.Error],
217+
[GetConfigRoot(envVariables: new Dictionary<string, string?>{{minimumLevelObjectKey, LogEventLevel.Error.ToString() } }), LogEventLevel.Error],
218+
[GetConfigRoot(
219219
appsettingsJsonLevel: minimumLevelObjectTemplate.Format(LogEventLevel.Error),
220220
appsettingsDevelopmentJsonLevel: minimumLevelObjectTemplate.Format(LogEventLevel.Debug)),
221-
LogEventLevel.Debug }
222-
};
221+
LogEventLevel.Debug ]
222+
];
223223

224224
[Theory]
225225
[MemberData(nameof(ObjectMinimumLevel))]
@@ -234,34 +234,31 @@ public void ObjectMinimumLevelCorrectOneIsEnabledOnLogger(IConfigurationRoot roo
234234
}
235235

236236
// currently only works in the .NET 4.6.1 and .NET Standard builds of Serilog.Settings.Configuration
237-
public static IEnumerable<object[]> MixedMinimumLevel => new List<object[]>
238-
{
239-
new object[]
240-
{
237+
public static IEnumerable<object[]> MixedMinimumLevel =>
238+
[
239+
[
241240
GetConfigRoot(
242241
appsettingsJsonLevel: minimumLevelObjectTemplate.Format(LogEventLevel.Error),
243242
appsettingsDevelopmentJsonLevel: minimumLevelFlatTemplate.Format(LogEventLevel.Debug)),
244243
LogEventLevel.Debug
245-
},
246-
new object[]
247-
{
244+
],
245+
[
248246
GetConfigRoot(
249247
appsettingsJsonLevel: minimumLevelFlatTemplate.Format(LogEventLevel.Error),
250248
appsettingsDevelopmentJsonLevel: minimumLevelObjectTemplate.Format(LogEventLevel.Debug)),
251249
LogEventLevel.Debug
252-
},
250+
],
253251
// precedence should be flat > object if from the same source
254-
new object[]
255-
{
252+
[
256253
GetConfigRoot(
257254
envVariables: new Dictionary<string, string?>()
258255
{
259256
{minimumLevelObjectKey, LogEventLevel.Error.ToString()},
260257
{minimumLevelFlatKey, LogEventLevel.Debug.ToString()}
261258
}),
262259
LogEventLevel.Debug
263-
}
264-
};
260+
]
261+
];
265262

266263
[Theory]
267264
[MemberData(nameof(MixedMinimumLevel))]

0 commit comments

Comments
 (0)