Skip to content

Commit dfb4df4

Browse files
authored
Merge pull request #414 from sungam3r/cleanup
Code cleanup
2 parents afeb558 + 7b32725 commit dfb4df4

14 files changed

+42
-242
lines changed

Diff for: .gitignore

+3-200
Original file line numberDiff line numberDiff line change
@@ -1,205 +1,8 @@
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
292
.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-
3+
bin/
4+
obj/
5+
test/
2036
artifacts/
2047

2058
.DS_Store

Diff for: src/Serilog.Settings.Configuration/Settings/Configuration/ConfigurationReader.cs

+2-2
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,

Diff for: src/Serilog.Settings.Configuration/Settings/Configuration/ObjectArgumentValue.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ bool TryCreateContainer([NotNullWhen(true)] out object? result)
101101
{
102102
var argumentValue = FromSection(section, _configurationAssemblies);
103103
var value = argumentValue.ConvertTo(elementType, resolutionContext);
104-
addMethod.Invoke(result, new[] { value });
104+
addMethod.Invoke(result, [value]);
105105
}
106106
return true;
107107
}

Diff for: src/Serilog.Settings.Configuration/Settings/Configuration/ResolutionContext.cs

+1-1
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
}

Diff for: test/Serilog.Settings.Configuration.Tests/ConfigurationReaderTests.cs

+26-29
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))]

Diff for: test/Serilog.Settings.Configuration.Tests/Support/ConfigurationReaderTestHelpers.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public static IConfigurationRoot GetConfigRoot(
5555

5656
configBuilder.AddJsonString(appsettingsJsonLevel ?? "{}");
5757
configBuilder.AddJsonString(appsettingsDevelopmentJsonLevel ?? "{}");
58-
configBuilder.Add(new ReloadableConfigurationSource(envVariables ?? new Dictionary<string, string?>()));
58+
configBuilder.Add(new ReloadableConfigurationSource(envVariables ?? []));
5959

6060
return configBuilder.Build();
6161
}

Diff for: test/Serilog.Settings.Configuration.Tests/Support/TestApp.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public TestApp(IMessageSink messageSink)
2626
{
2727
file.CopyTo(_workingDirectory.File(file.Name).FullName, overwrite: true);
2828
}
29-
_executables = new Dictionary<PublishMode, FileInfo>();
29+
_executables = [];
3030
}
3131

3232
async Task IAsyncLifetime.InitializeAsync()

Diff for: test/TestDummies/Console/DummyConsoleSink.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public DummyConsoleSink(ConsoleTheme? theme = null)
1717
[ThreadStatic]
1818
static List<LogEvent>? EmittedList;
1919

20-
public static List<LogEvent> Emitted => EmittedList ??= new List<LogEvent>();
20+
public static List<LogEvent> Emitted => EmittedList ??= [];
2121

2222
public void Emit(LogEvent logEvent)
2323
{

Diff for: test/TestDummies/DummyConfigurationSink.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public class DummyConfigurationSink : ILogEventSink
1515
[ThreadStatic]
1616
static IConfigurationSection? _configSection;
1717

18-
public static List<LogEvent> Emitted => _emitted ?? (_emitted = new List<LogEvent>());
18+
public static List<LogEvent> Emitted => _emitted ?? (_emitted = []);
1919

2020
public static IConfiguration? Configuration => _configuration;
2121

Diff for: test/TestDummies/DummyPolicy.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public bool TryDestructure(object value, ILogEventPropertyValueFactory propertyV
3434

3535
public class CustomCollection<T> : IEnumerable<T>
3636
{
37-
private readonly List<T> inner = new List<T>();
37+
private readonly List<T> inner = [];
3838

3939
public void Add(T item) => inner.Add(item);
4040

Diff for: test/TestDummies/DummyRollingFileAuditSink.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public class DummyRollingFileAuditSink : ILogEventSink
88
[ThreadStatic]
99
static List<LogEvent>? _emitted;
1010

11-
public static List<LogEvent> Emitted => _emitted ??= new List<LogEvent>();
11+
public static List<LogEvent> Emitted => _emitted ??= [];
1212

1313
public void Emit(LogEvent logEvent)
1414
{

0 commit comments

Comments
 (0)