Skip to content

Commit ad67a24

Browse files
snakefootMpdreamz
andauthored
Updated to NET8 since NET6 is obsolete (#469)
Co-authored-by: Martijn Laarman <[email protected]>
1 parent 2fd66e7 commit ad67a24

File tree

23 files changed

+54
-51
lines changed

23 files changed

+54
-51
lines changed

.github/workflows/bootstrap/action.yml

+6-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ runs:
1414
# Install .NET version as mandated by global.json
1515
- uses: actions/setup-dotnet@v4
1616
with:
17-
global-json-file: global.json
18-
17+
global-json-file: global.json
18+
dotnet-version: |
19+
6.x
20+
8.x
21+
1922
# Setup git config
20-
- uses: elastic/oblt-actions/git/setup@v1
23+
- uses: elastic/oblt-actions/git/setup@v1

dotnet-tools.json

+10-6
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,29 @@
66
"version": "2.3.1",
77
"commands": [
88
"minver"
9-
]
9+
],
10+
"rollForward": false
1011
},
1112
"assembly-differ": {
1213
"version": "0.14.0",
1314
"commands": [
1415
"assembly-differ"
15-
]
16+
],
17+
"rollForward": false
1618
},
1719
"release-notes": {
18-
"version": "0.5.0",
20+
"version": "0.6.0",
1921
"commands": [
2022
"release-notes"
21-
]
23+
],
24+
"rollForward": false
2225
},
2326
"nupkg-validator": {
24-
"version": "0.5.0",
27+
"version": "0.6.0",
2528
"commands": [
2629
"nupkg-validator"
27-
]
30+
],
31+
"rollForward": false
2832
}
2933
}
3034
}

global.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"sdk": {
3-
"version": "8.0.100",
3+
"version": "9.0.100",
44
"rollForward": "latestFeature",
55
"allowPrerelease": false
66
}
7-
}
7+
}

src/Elastic.Apm.NLog/Elastic.Apm.NLog.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFrameworks>netstandard2.0;net462</TargetFrameworks>
3+
<TargetFrameworks>netstandard2.0;net462;net8.0</TargetFrameworks>
44
<Title>Elastic APM NLog Layout Renderers</Title>
55
<Description>Enrich NLog log messages with APM TraceId and TransactionId.</Description>
66
<IsPackable>True</IsPackable>

src/Elastic.Apm.SerilogEnricher/Elastic.Apm.SerilogEnricher.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFrameworks>netstandard2.0;net462</TargetFrameworks>
3+
<TargetFrameworks>netstandard2.0;net462;net8.0</TargetFrameworks>
44
<Title>Elastic APM Serilog Enricher</Title>
55
<Description>Enrich Serilog log messages with APM TraceId and TransactionId.</Description>
66
<IsPackable>True</IsPackable>

src/Elastic.CommonSchema.Log4net/Elastic.CommonSchema.Log4net.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project Sdk="Microsoft.NET.Sdk">
33
<PropertyGroup>
4-
<TargetFrameworks>netstandard2.0;netstandard2.1;net462</TargetFrameworks>
4+
<TargetFrameworks>netstandard2.0;netstandard2.1;net462;net8.0</TargetFrameworks>
55
<Title>Elastic Common Schema (ECS) log4net Layout</Title>
66
<Description>log4net Layout that formats log events in accordance with Elastic Common Schema (ECS).</Description>
77
<IsPackable>True</IsPackable>

src/Elastic.CommonSchema.NLog/Elastic.CommonSchema.NLog.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project Sdk="Microsoft.NET.Sdk">
33
<PropertyGroup>
4-
<TargetFrameworks>netstandard2.0;netstandard2.1;net462</TargetFrameworks>
4+
<TargetFrameworks>netstandard2.0;netstandard2.1;net462;net8.0</TargetFrameworks>
55
<Title>Elastic Common Schema (ECS) NLog Layout</Title>
66
<Description>NLog Layout that formats log events in accordance with Elastic Common Schema (ECS).</Description>
77
<IsPackable>True</IsPackable>

src/Elastic.CommonSchema.Serilog/Elastic.CommonSchema.Serilog.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<Project Sdk="Microsoft.NET.Sdk">
44
<PropertyGroup>
5-
<TargetFrameworks>netstandard2.0;netstandard2.1;net462</TargetFrameworks>
5+
<TargetFrameworks>netstandard2.0;netstandard2.1;net462;net8.0</TargetFrameworks>
66
<Title>Elastic Common Schema (ECS) Serilog Formatter</Title>
77
<Description>Serilog TextFormatter that formats log events in accordance with Elastic Common Schema (ECS).</Description>
88
<IsPackable>True</IsPackable>

src/Elastic.CommonSchema.Serilog/LogEventConverter.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -183,11 +183,11 @@ private static object PropertyValueToObject(LogEventPropertyValue propertyValue)
183183
switch (propertyValue)
184184
{
185185
case SequenceValue values:
186-
return values.Elements.Select(PropertyValueToObject).ToArray();
186+
return values.Elements.Select((e) => PropertyValueToObject(e)).ToArray();
187187
case ScalarValue sv:
188188
return sv.Value;
189189
case DictionaryValue dv:
190-
return dv.Elements.ToDictionary(keySelector: kvp => kvp.Key.Value.ToString(),
190+
return dv.Elements.ToDictionary(keySelector: kvp => kvp.Key.Value.ToString() ?? string.Empty,
191191
elementSelector: (kvp) => PropertyValueToObject(kvp.Value));
192192
case StructureValue ov:
193193
{

src/Elastic.CommonSchema/Elastic.CommonSchema.csproj

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project Sdk="Microsoft.NET.Sdk">
33
<PropertyGroup>
4-
<TargetFrameworks>netstandard2.0;netstandard2.1;net462;net6.0</TargetFrameworks>
4+
<TargetFrameworks>netstandard2.0;netstandard2.1;net462;net8.0</TargetFrameworks>
55
<Title>Elastic Common Schema (ECS) Types</Title>
66
<Description>Maps Elastic Common Schema (ECS) to .NET types including (de)serialization using System.Text.Json</Description>
77
<LangVersion>latest</LangVersion>
@@ -14,10 +14,9 @@
1414
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1515
</PackageReference>
1616
</ItemGroup>
17-
<ItemGroup Condition="$(TargetFramework) == 'net462' OR $(TargetFramework) == 'netstandard2.0' OR $(TargetFramework) == 'netstandard2.1'">
18-
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="5.0.0" />
17+
<ItemGroup Condition=" $(TargetFramework.StartsWith('netstandard2.')) OR $(TargetFramework.StartsWith('net4')) ">
18+
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="8.0.0" />
1919
<PackageReference Include="System.Text.Json" Version="8.0.5" />
20-
2120
</ItemGroup>
2221
<ItemGroup>
2322
<Compile Include="..\NullableExtensions.cs" />

src/Elastic.Extensions.Logging.Common/Elastic.Extensions.Logging.Common.csproj

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>netstandard2.0;netstandard2.1</TargetFrameworks>
4+
<TargetFrameworks>netstandard2.0;netstandard2.1;net8.0</TargetFrameworks>
55
<Title>Common Abstactions For ECS For Microsoft.Extensions.Logging</Title>
66
<Description>Transient dependency, do not install directly. Common Abstactions For ECS For Microsoft.Extensions.Logging</Description>
77
<PackageTags>Logging;LoggerProvider;Elasticsearch;Console;ELK;Kibana;Logstash;Tracing;Diagnostics;Log;Trace;ECS</PackageTags>
@@ -13,8 +13,9 @@
1313
<ItemGroup>
1414
<ProjectReference Include="..\Elastic.CommonSchema\Elastic.CommonSchema.csproj"/>
1515
</ItemGroup>
16+
1617
<ItemGroup>
17-
<PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0"/>
18+
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0"/>
1819
</ItemGroup>
1920

2021
</Project>

src/Elastic.Extensions.Logging.Common/LogEventBuilderExtensions.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ void AddScopeValue<TLocalState>(TLocalState scope, LogEvent log)
2121

2222
var scopeValues = (scope as IEnumerable<KeyValuePair<string, object>>)?.ToList();
2323
var scopeName = scopeValues != null && scopeValues.Any(kv => kv.Key == "{OriginalFormat}")
24-
? scope.ToString()
24+
? (scope.ToString() ?? string.Empty)
2525
: FormatValue(scope, options, 0, scope.GetType().Name);
2626
log.Scopes.Add(scopeName);
2727

@@ -139,7 +139,7 @@ private static string FormatValue(object value, ILogEventCreationOptions options
139139
if (depth < 1 && value is IEnumerable enumerable)
140140
return FormatEnumerable(enumerable, depth, options);
141141

142-
return defaultFallback ?? value.ToString();
142+
return defaultFallback ?? value.ToString() ?? string.Empty;
143143
}
144144
}
145145

src/Elastic.Extensions.Logging.Console/Elastic.Extensions.Logging.Console.csproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>netstandard2.0;netstandard2.1</TargetFrameworks>
4+
<TargetFrameworks>netstandard2.0;netstandard2.1;net8.0</TargetFrameworks>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Title>ECS Console Logger for Microsoft.Extensions.Logging</Title>
77
<Description>ECS Console Logger for Microsoft.Extensions.Logging. Writes Elastic Common Schema (ECS), with semantic logging of structured data from message and scope values to console out, use filebeat/Elastic-Agent to send these to Elastic</Description>
@@ -11,7 +11,7 @@
1111
</PropertyGroup>
1212

1313
<ItemGroup>
14-
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="6.0.0"/>
14+
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.0"/>
1515
</ItemGroup>
1616

1717
<ItemGroup>

src/Elastic.Extensions.Logging/Elastic.Extensions.Logging.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
</PropertyGroup>
1111

1212
<ItemGroup>
13-
<PackageReference Include="Microsoft.Extensions.Logging.Configuration" Version="2.1.0" />
13+
<PackageReference Include="Microsoft.Extensions.Logging.Configuration" Version="8.0.0" />
1414
<ProjectReference Include="..\Elastic.CommonSchema\Elastic.CommonSchema.csproj" />
1515
<ProjectReference Include="..\Elastic.Extensions.Logging.Common\Elastic.Extensions.Logging.Common.csproj" />
1616
<ProjectReference Include="..\Elastic.Ingest.Elasticsearch.CommonSchema\Elastic.Ingest.Elasticsearch.CommonSchema.csproj" />

src/Elastic.Extensions.Logging/ElasticsearchLogger.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,14 @@ internal ElasticsearchLogger(
4343
_scopeProvider = scopeProvider;
4444
}
4545

46-
private class EmptyDisposable : IDisposable
46+
private sealed class EmptyDisposable : IDisposable
4747
{
4848
public void Dispose() { }
4949
}
5050
private readonly IDisposable _emptyScope = new EmptyDisposable();
5151

5252
/// <inheritdoc cref="ILogger.BeginScope{TState}"/>
53-
public IDisposable BeginScope<TState>(TState state) => _scopeProvider?.Push(state) ?? _emptyScope;
53+
IDisposable ILogger.BeginScope<TState>(TState state) => _scopeProvider?.Push(state) ?? _emptyScope;
5454

5555
/// <inheritdoc cref="ILogger.IsEnabled"/>
5656
public bool IsEnabled(LogLevel logLevel) => _options.IsEnabled;

src/Elastic.Extensions.Logging/ElasticsearchLoggerProvider.cs

+5-9
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@
2020
using Microsoft.Extensions.Logging;
2121
using Microsoft.Extensions.Options;
2222

23-
#if NETSTANDARD2_1_OR_GREATER
24-
using System.Buffers;
25-
#endif
26-
2723
namespace Elastic.Extensions.Logging
2824
{
2925
/// <summary>
@@ -35,14 +31,14 @@ public class ElasticsearchLoggerProvider : ILoggerProvider, ISupportExternalScop
3531
{
3632
private readonly IChannelSetup[] _channelConfigurations;
3733
private readonly IOptionsMonitor<ElasticsearchLoggerOptions> _options;
38-
private readonly IDisposable _optionsReloadToken;
34+
private readonly IDisposable? _optionsReloadToken;
3935
private IExternalScopeProvider? _scopeProvider;
4036
private IBufferedChannel<LogEvent> _shipper;
4137

4238
private static readonly LogEventWriter LogEventWriterInstance = new()
4339
{
4440
WriteToStreamAsync = static async (stream, logEvent, ctx) => await logEvent.SerializeAsync(stream, ctx).ConfigureAwait(false),
45-
#if NETSTANDARD2_1_OR_GREATER
41+
#if NETSTANDARD2_1_OR_GREATER || NET8_0_OR_GREATER
4642
WriteToArrayBuffer = static (arrayBufferWriter, logEvent) =>
4743
{
4844
var serialized = logEvent.SerializeToUtf8Bytes(); // TODO - Performance optimisation to avoid array allocation
@@ -84,7 +80,7 @@ public ILogger CreateLogger(string name) =>
8480
/// <inheritdoc cref="IDisposable.Dispose"/>
8581
public void Dispose()
8682
{
87-
_optionsReloadToken.Dispose();
83+
_optionsReloadToken?.Dispose();
8884
_shipper.Dispose();
8985
}
9086

@@ -216,8 +212,8 @@ private IBufferedChannel<LogEvent> CreatIngestChannel(ElasticsearchLoggerOptions
216212

217213
private sealed class LogEventWriter : IElasticsearchEventWriter<LogEvent>
218214
{
219-
#if NETSTANDARD2_1_OR_GREATER
220-
public Action<ArrayBufferWriter<byte>, LogEvent>? WriteToArrayBuffer { get; set; }
215+
#if NETSTANDARD2_1_OR_GREATER || NET8_0_OR_GREATER
216+
public Action<System.Buffers.ArrayBufferWriter<byte>, LogEvent>? WriteToArrayBuffer { get; set; }
221217
#endif
222218

223219
public Func<Stream, LogEvent, CancellationToken, Task>? WriteToStreamAsync { get; set; }

src/Elastic.Ingest.Elasticsearch.CommonSchema/Elastic.Ingest.Elasticsearch.CommonSchema.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>netstandard2.0;netstandard2.1</TargetFrameworks>
4+
<TargetFrameworks>netstandard2.0;netstandard2.1;net8.0</TargetFrameworks>
55
<IsPackable>True</IsPackable>
66
</PropertyGroup>
77

src/Elastic.NLog.Targets/Elastic.NLog.Targets.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>netstandard2.0</TargetFrameworks>
4+
<TargetFrameworks>netstandard2.0;netstandard2.1;net8.0</TargetFrameworks>
55
<Title>Elasticsearch NLog Target</Title>
66
<Description>NLog Target that exports directly to Elastic Cloud or individual Elasticsearch nodes</Description>
77
<RootNamespace>NLog.Targets</RootNamespace>

src/Elastic.Serilog.Enrichers.Web/Elastic.Serilog.Enrichers.Web.csproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net6.0;net8.0;net462</TargetFrameworks>
4+
<TargetFrameworks>net8.0;net462</TargetFrameworks>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
77
<Title>Elastic Common Schema (ECS) Serilog Enricher for Web proeprties</Title>

src/Elastic.Serilog.Sinks/Elastic.Serilog.Sinks.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>netstandard2.0;netstandard2.1</TargetFrameworks>
4+
<TargetFrameworks>netstandard2.0;netstandard2.1;net8.0</TargetFrameworks>
55
<Nullable>enable</Nullable>
66
<IsPackable>True</IsPackable>
77
</PropertyGroup>

tests/Elastic.CommonSchema.Serilog.Tests/Elastic.CommonSchema.Serilog.Tests.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" />
11+
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
1212
<PackageReference Include="Serilog.Enrichers.Environment" Version="2.1.3" />
1313
<PackageReference Include="Serilog.Enrichers.Process" Version="2.0.1" />
1414
<PackageReference Include="Serilog.Enrichers.Thread" Version="3.2.0-dev-00747" />

tests/Elastic.CommonSchema.Tests/Elastic.CommonSchema.Tests.csproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net8.0;net6.0</TargetFrameworks>
4+
<TargetFrameworks>net8.0</TargetFrameworks>
55
<IsPackable>false</IsPackable>
66
</PropertyGroup>
77

tests/Elastic.Serilog.Sinks.Tests/Elastic.Serilog.Sinks.Tests.csproj

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net6.0</TargetFramework>
4+
<TargetFramework>net8.0</TargetFramework>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
77
<LangVersion>preview</LangVersion>
@@ -12,8 +12,8 @@
1212
</ItemGroup>
1313

1414
<ItemGroup>
15-
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0"/>
16-
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0"/>
15+
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0"/>
16+
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.1"/>
1717
<PackageReference Include="Serilog.Settings.Configuration" Version="8.0.2"/>
1818
</ItemGroup>
1919

0 commit comments

Comments
 (0)