[repo] Replace .NET6 target with .NET9 (#5832)

Co-authored-by: Mikel Blanchard <mblanchard@macrosssoftware.com>
Co-authored-by: Piotr Kiełkowicz <pkiekowicz@splunk.com>
This commit is contained in:
Rajkumar Rangaraj 2024-09-19 17:32:10 -07:00 committed by GitHub
parent 6e1b5ab577
commit cd01f932a6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
19 changed files with 73 additions and 53 deletions

View File

@ -41,7 +41,7 @@ csharp_indent_labels = flush_left
# Modifier preferences # Modifier preferences
csharp_preferred_modifier_order = public,private,protected,internal,file,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,required,volatile,async:suggestion csharp_preferred_modifier_order = public,private,protected,internal,file,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,required,volatile,async:suggestion
dotnet_style_require_accessibility_modifiers = for_non_interface_members:silent dotnet_style_require_accessibility_modifiers = for_non_interface_members:suggestion
# this. preferences # this. preferences
dotnet_style_qualification_for_field = true:suggestion dotnet_style_qualification_for_field = true:suggestion
@ -53,8 +53,8 @@ dotnet_style_qualification_for_event = true:suggestion
csharp_style_var_for_built_in_types = true:silent csharp_style_var_for_built_in_types = true:silent
csharp_style_var_when_type_is_apparent = true:silent csharp_style_var_when_type_is_apparent = true:silent
csharp_style_var_elsewhere = true:silent csharp_style_var_elsewhere = true:silent
dotnet_style_predefined_type_for_locals_parameters_members = true:silent dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
dotnet_style_predefined_type_for_member_access = true:silent dotnet_style_predefined_type_for_member_access = true:suggestion
# name all constant fields using PascalCase # name all constant fields using PascalCase
dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = suggestion dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = suggestion
@ -75,6 +75,7 @@ dotnet_style_readonly_field = true:suggestion
csharp_style_implicit_object_creation_when_type_is_apparent = true:suggestion csharp_style_implicit_object_creation_when_type_is_apparent = true:suggestion
dotnet_style_prefer_simplified_interpolation = true:suggestion dotnet_style_prefer_simplified_interpolation = true:suggestion
dotnet_style_object_initializer = true:suggestion dotnet_style_object_initializer = true:suggestion
csharp_style_prefer_primary_constructors = false:none
# Expression-level preferences # Expression-level preferences
dotnet_style_object_initializer = true:suggestion dotnet_style_object_initializer = true:suggestion
@ -82,21 +83,23 @@ dotnet_style_collection_initializer = true:suggestion
dotnet_style_explicit_tuple_names = true:suggestion dotnet_style_explicit_tuple_names = true:suggestion
dotnet_style_coalesce_expression = true:suggestion dotnet_style_coalesce_expression = true:suggestion
dotnet_style_null_propagation = true:suggestion dotnet_style_null_propagation = true:suggestion
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:silent dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
dotnet_style_prefer_inferred_tuple_names = true:suggestion dotnet_style_prefer_inferred_tuple_names = true:suggestion
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
dotnet_style_prefer_auto_properties = true:silent dotnet_style_prefer_auto_properties = true:suggestion
dotnet_style_prefer_conditional_expression_over_assignment = true:silent dotnet_style_prefer_conditional_expression_over_assignment = true:suggestion
dotnet_style_prefer_conditional_expression_over_return = true:silent dotnet_style_prefer_conditional_expression_over_return = true:suggestion
csharp_prefer_simple_default_expression = true:suggestion csharp_prefer_simple_default_expression = true:suggestion
csharp_style_unused_value_expression_statement_preference = discard_variable:none
# Expression-bodied members # Expression-bodied members
csharp_style_expression_bodied_methods = false:silent csharp_style_expression_bodied_methods = true:suggestion
csharp_style_expression_bodied_constructors = false:silent dotnet_diagnostic.IDE0022.severity = suggestion # dotnet format doesn't respect the suggestion in the line above
csharp_style_expression_bodied_operators = false:silent csharp_style_expression_bodied_constructors = false:warning
csharp_style_expression_bodied_properties = true:silent csharp_style_expression_bodied_operators = true:suggestion
csharp_style_expression_bodied_indexers = true:silent csharp_style_expression_bodied_properties = true:suggestion
csharp_style_expression_bodied_accessors = true:silent csharp_style_expression_bodied_indexers = true:suggestion
csharp_style_expression_bodied_accessors = true:suggestion
# Pattern matching # Pattern matching
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
@ -113,6 +116,7 @@ csharp_style_prefer_range_operator = false:none
csharp_style_pattern_local_over_anonymous_function = true:suggestion csharp_style_pattern_local_over_anonymous_function = true:suggestion
csharp_style_deconstructed_variable_declaration = true:suggestion csharp_style_deconstructed_variable_declaration = true:suggestion
csharp_style_namespace_declarations = file_scoped:warning csharp_style_namespace_declarations = file_scoped:warning
dotnet_style_namespace_match_folder = false:none
# Space preferences # Space preferences
csharp_space_after_cast = false csharp_space_after_cast = false
@ -128,10 +132,10 @@ csharp_space_between_method_declaration_parameter_list_parentheses = false
csharp_space_between_parentheses = false csharp_space_between_parentheses = false
# Parentheses preferences # Parentheses preferences
dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:silent dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:suggestion
dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:silent dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:suggestion
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:silent dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:suggestion
dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent dotnet_style_parentheses_in_other_operators = never_if_unnecessary:suggestion
# Code analyzers # Code analyzers
# CA1031: Do not catch general exception types # CA1031: Do not catch general exception types

View File

@ -48,7 +48,7 @@ body:
- type: input - type: input
attributes: attributes:
label: Runtime Version label: Runtime Version
description: What .NET runtime version did you use? (e.g. `net462`, `net48`, `netcoreapp3.1`, `net6.0` etc. You can find this information from the `*.csproj` file) description: What .NET runtime version did you use? (e.g. `net462`, `net48`, `net8.0`, etc. You can find this information from the `*.csproj` file)
validations: validations:
required: true required: true

View File

@ -24,7 +24,7 @@ on:
required: false required: false
type: string type: string
tfm-list: tfm-list:
default: '[ "net462", "net6.0", "net8.0" ]' default: '[ "net462", "net8.0", "net9.0" ]'
required: false required: false
type: string type: string
@ -42,7 +42,7 @@ jobs:
- os: otel-linux-arm64 - os: otel-linux-arm64
version: net462 version: net462
- os: otel-linux-arm64 - os: otel-linux-arm64
version: net6.0 version: net8.0
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:

View File

@ -111,7 +111,7 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
version: [ net6.0, net8.0 ] version: [ net8.0, net9.0 ]
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Run OTLP Exporter docker compose - name: Run OTLP Exporter docker compose
@ -129,7 +129,7 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
version: [ net6.0, net8.0 ] version: [ net8.0, net9.0 ]
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Run W3C Trace Context docker compose - name: Run W3C Trace Context docker compose

View File

@ -13,6 +13,9 @@ jobs:
- name: check out code - name: check out code
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Setup dotnet
uses: actions/setup-dotnet@v4
- name: install docfx - name: install docfx
run: dotnet tool install -g docfx run: dotnet tool install -g docfx

View File

@ -12,7 +12,7 @@ jobs:
fail-fast: false # ensures the entire test matrix is run, even if one permutation fails fail-fast: false # ensures the entire test matrix is run, even if one permutation fails
matrix: matrix:
os: [ ubuntu-latest, windows-latest ] os: [ ubuntu-latest, windows-latest ]
version: [ net8.0 ] version: [ net8.0, net9.0 ]
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:

View File

@ -44,7 +44,7 @@ You can contribute to this project from a Windows, macOS or Linux machine.
On all platforms, the minimum requirements are: On all platforms, the minimum requirements are:
* Git client and command line tools. * Git client and command line tools.
* .NET 8.0 * .NET 9.0
### Linux or MacOS ### Linux or MacOS

View File

@ -97,10 +97,10 @@
<PackageVersion Include="xunit.runner.visualstudio" Version="[2.8.2,3.0)" /> <PackageVersion Include="xunit.runner.visualstudio" Version="[2.8.2,3.0)" />
</ItemGroup> </ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
<PackageVersion Include="Microsoft.AspNetCore.TestHost" Version="6.0.33" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'"> <ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
<PackageVersion Include="Microsoft.AspNetCore.TestHost" Version="8.0.8" /> <PackageVersion Include="Microsoft.AspNetCore.TestHost" Version="8.0.8" />
</ItemGroup> </ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net9.0'">
<PackageVersion Include="Microsoft.AspNetCore.TestHost" Version="9.0.0-rc.1.24452.1" />
</ItemGroup>
</Project> </Project>

View File

@ -31,8 +31,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{7CB2F02E
build\debug.snk = build\debug.snk build\debug.snk = build\debug.snk
Directory.Packages.props = Directory.Packages.props Directory.Packages.props = Directory.Packages.props
build\docfx.cmd = build\docfx.cmd build\docfx.cmd = build\docfx.cmd
build\docker-compose.net6.0.yml = build\docker-compose.net6.0.yml
build\docker-compose.net8.0.yml = build\docker-compose.net8.0.yml build\docker-compose.net8.0.yml = build\docker-compose.net8.0.yml
build\docker-compose.net9.0.yml = build\docker-compose.net9.0.yml
build\GlobalAttrExclusions.txt = build\GlobalAttrExclusions.txt build\GlobalAttrExclusions.txt = build\GlobalAttrExclusions.txt
build\opentelemetry-icon-color.png = build\opentelemetry-icon-color.png build\opentelemetry-icon-color.png = build\opentelemetry-icon-color.png
build\OpenTelemetry.prod.loose.ruleset = build\OpenTelemetry.prod.loose.ruleset build\OpenTelemetry.prod.loose.ruleset = build\OpenTelemetry.prod.loose.ruleset

View File

@ -8,7 +8,7 @@
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<DefaultTargetFrameworkForExampleApps>net8.0</DefaultTargetFrameworkForExampleApps> <DefaultTargetFrameworkForExampleApps>net9.0</DefaultTargetFrameworkForExampleApps>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="$(MSBuildProjectName.EndsWith('.Tests'))"> <PropertyGroup Condition="$(MSBuildProjectName.EndsWith('.Tests'))">

View File

@ -33,6 +33,13 @@
<ContinuousIntegrationBuild Condition="'$(Deterministic)'=='true'">true</ContinuousIntegrationBuild> <ContinuousIntegrationBuild Condition="'$(Deterministic)'=='true'">true</ContinuousIntegrationBuild>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<!-- Note: Disable net6.0 target for package validation because it has been
removed. It should be possible to remove this once a stable version has been
released to NuGet without net6.0. -->
<PackageValidationBaselineFrameworkToIgnore Include="net6.0" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="MinVer" PrivateAssets="All" Condition="'$(IntegrationBuild)' != 'true'" /> <PackageReference Include="MinVer" PrivateAssets="All" Condition="'$(IntegrationBuild)' != 'true'" />
<PackageReference Include="Microsoft.SourceLink.GitHub" PrivateAssets="All" Condition="'$(IntegrationBuild)' != 'true'" /> <PackageReference Include="Microsoft.SourceLink.GitHub" PrivateAssets="All" Condition="'$(IntegrationBuild)' != 'true'" />

View File

@ -28,18 +28,18 @@
<NetFrameworkSupportedVersions>net481;net48;net472;net471;net47;net462</NetFrameworkSupportedVersions> <NetFrameworkSupportedVersions>net481;net48;net472;net471;net47;net462</NetFrameworkSupportedVersions>
<!-- production TFMs --> <!-- production TFMs -->
<TargetFrameworksForLibraries>net8.0;net6.0;netstandard2.0;$(NetFrameworkMinimumSupportedVersion)</TargetFrameworksForLibraries> <TargetFrameworksForLibraries>net9.0;net8.0;netstandard2.0;$(NetFrameworkMinimumSupportedVersion)</TargetFrameworksForLibraries>
<TargetFrameworksForLibrariesExtended>net8.0;net6.0;netstandard2.1;netstandard2.0;$(NetFrameworkMinimumSupportedVersion)</TargetFrameworksForLibrariesExtended> <TargetFrameworksForLibrariesExtended>net9.0;net8.0;netstandard2.1;netstandard2.0;$(NetFrameworkMinimumSupportedVersion)</TargetFrameworksForLibrariesExtended>
<TargetFrameworksForPrometheusAspNetCore>net8.0;net6.0</TargetFrameworksForPrometheusAspNetCore> <TargetFrameworksForPrometheusAspNetCore>net9.0;net8.0</TargetFrameworksForPrometheusAspNetCore>
<!-- non-production TFMs --> <!-- non-production TFMs -->
<TargetFrameworksForAspNetCoreTests>net8.0;net6.0</TargetFrameworksForAspNetCoreTests> <TargetFrameworksForAspNetCoreTests>net9.0;net8.0</TargetFrameworksForAspNetCoreTests>
<TargetFrameworksForAotCompatibilityTests>net8.0</TargetFrameworksForAotCompatibilityTests> <TargetFrameworksForAotCompatibilityTests>net9.0;net8.0</TargetFrameworksForAotCompatibilityTests>
<TargetFrameworksForDocs>net8.0;net6.0</TargetFrameworksForDocs> <TargetFrameworksForDocs>net9.0;net8.0</TargetFrameworksForDocs>
<TargetFrameworksForDocs Condition="$(OS) == 'Windows_NT' And '$(UsingMicrosoftNETSdkWeb)' != 'True'"> <TargetFrameworksForDocs Condition="$(OS) == 'Windows_NT' And '$(UsingMicrosoftNETSdkWeb)' != 'True'">
$(TargetFrameworksForDocs);$(NetFrameworkSupportedVersions) $(TargetFrameworksForDocs);$(NetFrameworkSupportedVersions)
</TargetFrameworksForDocs> </TargetFrameworksForDocs>
<TargetFrameworksForTests>net8.0;net6.0</TargetFrameworksForTests> <TargetFrameworksForTests>net9.0;net8.0</TargetFrameworksForTests>
<TargetFrameworksForTests Condition="$(OS) == 'Windows_NT'"> <TargetFrameworksForTests Condition="$(OS) == 'Windows_NT'">
$(TargetFrameworksForTests);$(NetFrameworkMinimumSupportedVersion) $(TargetFrameworksForTests);$(NetFrameworkMinimumSupportedVersion)
</TargetFrameworksForTests> </TargetFrameworksForTests>

View File

@ -1,9 +0,0 @@
version: '3.7'
services:
tests:
build:
args:
PUBLISH_FRAMEWORK: net6.0
TEST_SDK_VERSION: "6.0"
BUILD_SDK_VERSION: "8.0"

View File

@ -6,4 +6,4 @@ services:
args: args:
PUBLISH_FRAMEWORK: net8.0 PUBLISH_FRAMEWORK: net8.0
TEST_SDK_VERSION: "8.0" TEST_SDK_VERSION: "8.0"
BUILD_SDK_VERSION: "8.0" BUILD_SDK_VERSION: "9.0"

View File

@ -0,0 +1,9 @@
version: '3.7'
services:
tests:
build:
args:
PUBLISH_FRAMEWORK: net9.0
TEST_SDK_VERSION: "9.0"
BUILD_SDK_VERSION: "9.0"

View File

@ -1,6 +1,6 @@
{ {
"sdk": { "sdk": {
"rollForward": "latestFeature", "rollForward": "latestFeature",
"version": "8.0.100" "version": "9.0.100-rc.1.24452.12"
} }
} }

View File

@ -66,7 +66,9 @@ internal sealed class SelfDiagnosticsConfigParser
this.configBuffer = buffer; this.configBuffer = buffer;
} }
file.Read(buffer, 0, buffer.Length); // TODO: Fix CA2022 - Avoid inexact read with 'System.IO.FileStream.Read(byte[], int, int)'
// Added _ = as a workaround to suppress the warning
_ = file.Read(buffer, 0, buffer.Length);
string configJson = Encoding.UTF8.GetString(buffer); string configJson = Encoding.UTF8.GetString(buffer);
if (!TryParseLogDirectory(configJson, out logDirectory)) if (!TryParseLogDirectory(configJson, out logDirectory))

View File

@ -2,8 +2,8 @@
# This should be run from the root of the repo: # This should be run from the root of the repo:
# docker build --file test/OpenTelemetry.Instrumentation.W3cTraceContext.Tests/Dockerfile . # docker build --file test/OpenTelemetry.Instrumentation.W3cTraceContext.Tests/Dockerfile .
ARG BUILD_SDK_VERSION=8.0 ARG BUILD_SDK_VERSION=9.0
ARG TEST_SDK_VERSION=8.0 ARG TEST_SDK_VERSION=9.0
FROM ubuntu AS w3c FROM ubuntu AS w3c
#Install git #Install git
@ -13,7 +13,7 @@ RUN git clone --branch level-1 https://github.com/w3c/trace-context.git
FROM mcr.microsoft.com/dotnet/sdk:${BUILD_SDK_VERSION} AS build FROM mcr.microsoft.com/dotnet/sdk:${BUILD_SDK_VERSION} AS build
ARG PUBLISH_CONFIGURATION=Release ARG PUBLISH_CONFIGURATION=Release
ARG PUBLISH_FRAMEWORK=net8.0 ARG PUBLISH_FRAMEWORK=net9.0
WORKDIR /repo WORKDIR /repo
COPY . ./ COPY . ./
WORKDIR "/repo/test/OpenTelemetry.Instrumentation.W3cTraceContext.Tests" WORKDIR "/repo/test/OpenTelemetry.Instrumentation.W3cTraceContext.Tests"

View File

@ -124,7 +124,9 @@ public class SelfDiagnosticsEventListenerTest
using FileStream file = File.Open(LOGFILEPATH, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete); using FileStream file = File.Open(LOGFILEPATH, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete);
var buffer = new byte[256]; var buffer = new byte[256];
file.Read(buffer, 0, buffer.Length);
// Suppress CA2022 error: Avoid inexact read with 'System.IO.FileStream.Read(byte[], int, int)'
_ = file.Read(buffer, 0, buffer.Length);
Assert.Equal('\0', (char)buffer[0]); Assert.Equal('\0', (char)buffer[0]);
} }
@ -256,7 +258,9 @@ public class SelfDiagnosticsEventListenerTest
{ {
using FileStream file = File.Open(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete); using FileStream file = File.Open(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete);
var buffer = new byte[256]; var buffer = new byte[256];
file.Read(buffer, 0, buffer.Length);
// Suppress CA2022 error: Avoid inexact read with 'System.IO.FileStream.Read(byte[], int, int)'
_ = file.Read(buffer, 0, buffer.Length);
string logLine = Encoding.UTF8.GetString(buffer); string logLine = Encoding.UTF8.GetString(buffer);
string logMessage = ParseLogMessage(logLine); string logMessage = ParseLogMessage(logLine);
Assert.StartsWith(eventMessage, logMessage); Assert.StartsWith(eventMessage, logMessage);