Skip to content

Commit 08e9025

Browse files
authored
Merge pull request #280 from sungam3r/style
Code cleanup
2 parents 2a61b4b + f709698 commit 08e9025

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+2819
-2943
lines changed

.editorconfig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ trim_trailing_whitespace = true
55
insert_final_newline = true
66
indent_style = space
77
indent_size = 4
8+
charset = utf-8
89

910
[*.{csproj,json,config,yml,props}]
1011
indent_size = 2
@@ -14,3 +15,8 @@ end_of_line = lf
1415

1516
[*.{cmd, bat}]
1617
end_of_line = crlf
18+
19+
# C# formatting settings - Namespace options
20+
csharp_style_namespace_declarations = file_scoped:suggestion
21+
22+
csharp_style_prefer_switch_expression = true:suggestion

Build.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ $commitHash = $(git rev-parse --short HEAD)
1616
$buildSuffix = @{ $true = "$($suffix)-$($commitHash)"; $false = "$($branch)-$($commitHash)" }[$suffix -ne ""]
1717

1818
echo "build: Package version suffix is $suffix"
19-
echo "build: Build version suffix is $buildSuffix"
19+
echo "build: Build version suffix is $buildSuffix"
2020

2121
foreach ($src in ls src/*) {
2222
Push-Location $src
@@ -29,7 +29,7 @@ foreach ($src in ls src/*) {
2929
} else {
3030
& dotnet pack -c Release -o ..\..\artifacts --no-build
3131
}
32-
if($LASTEXITCODE -ne 0) { exit 1 }
32+
if($LASTEXITCODE -ne 0) { exit 1 }
3333

3434
Pop-Location
3535
}

Directory.Build.props

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<Project>
2+
<PropertyGroup>
3+
<LangVersion>latest</LangVersion>
4+
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
5+
<SignAssembly>true</SignAssembly>
6+
<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
7+
<AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)assets/Serilog.snk</AssemblyOriginatorKeyFile>
8+
<Nullable>enable</Nullable>
9+
<ImplicitUsings>enable</ImplicitUsings>
10+
</PropertyGroup>
11+
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'">
12+
<Reference Include="System" />
13+
<Reference Include="System.Core" />
14+
<Reference Include="Microsoft.CSharp" />
15+
</ItemGroup>
16+
</Project>

Directory.Build.targets

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<Project>
2+
3+
<ItemGroup>
4+
<Using Remove="System.Net.Http" />
5+
</ItemGroup>
6+
7+
</Project>

build.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#!/bin/bash
1+
#!/bin/bash
22

3-
set -e
3+
set -e
44
dotnet --info
55
dotnet --list-sdks
66
dotnet restore

example/Sample/Program.cs

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,35 @@
1-
using System;
2-
using System.IO;
31
using Serilog;
42
using Serilog.Debugging;
53

6-
namespace Sample
4+
namespace Sample;
5+
6+
public class Program
77
{
8-
public class Program
8+
public static void Main(string[] args)
99
{
10-
public static void Main(string[] args)
11-
{
12-
SelfLog.Enable(Console.Out);
10+
SelfLog.Enable(Console.Out);
1311

14-
var sw = System.Diagnostics.Stopwatch.StartNew();
12+
var sw = System.Diagnostics.Stopwatch.StartNew();
1513

16-
Log.Logger = new LoggerConfiguration()
17-
.WriteTo.File("log.txt")
18-
.CreateLogger();
14+
Log.Logger = new LoggerConfiguration()
15+
.WriteTo.File("log.txt")
16+
.CreateLogger();
1917

20-
for (var i = 0; i < 1000000; ++i)
21-
{
22-
Log.Information("Hello, file logger!");
23-
}
18+
for (var i = 0; i < 1000000; ++i)
19+
{
20+
Log.Information("Hello, file logger!");
21+
}
2422

25-
Log.CloseAndFlush();
23+
Log.CloseAndFlush();
2624

27-
sw.Stop();
25+
sw.Stop();
2826

29-
Console.WriteLine($"Elapsed: {sw.ElapsedMilliseconds} ms");
30-
Console.WriteLine($"Size: {new FileInfo("log.txt").Length}");
27+
Console.WriteLine($"Elapsed: {sw.ElapsedMilliseconds} ms");
28+
Console.WriteLine($"Size: {new FileInfo("log.txt").Length}");
3129

32-
Console.WriteLine("Press any key to delete the temporary log file...");
33-
Console.ReadKey(true);
30+
Console.WriteLine("Press any key to delete the temporary log file...");
31+
Console.ReadKey(true);
3432

35-
File.Delete("log.txt");
36-
}
33+
File.Delete("log.txt");
3734
}
3835
}

example/Sample/Sample.csproj

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<TargetFrameworks>net48;net6.0</TargetFrameworks>
5-
<LangVersion>8.0</LangVersion>
6-
<Nullable>enable</Nullable>
7-
<AssemblyName>Sample</AssemblyName>
85
<OutputType>Exe</OutputType>
9-
<PackageId>Sample</PackageId>
106
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
117
</PropertyGroup>
128

serilog-sinks-file.sln

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio 15
4-
VisualStudioVersion = 15.0.26730.15
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.5.33424.131
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{037440DE-440B-4129-9F7A-09B42D00397E}"
77
EndProject
@@ -11,6 +11,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "assets", "assets", "{E9D1B5
1111
appveyor.yml = appveyor.yml
1212
Build.ps1 = Build.ps1
1313
build.sh = build.sh
14+
Directory.Build.props = Directory.Build.props
15+
Directory.Build.targets = Directory.Build.targets
1416
README.md = README.md
1517
assets\Serilog.snk = assets\Serilog.snk
1618
EndProjectSection

0 commit comments

Comments
 (0)