From cd01f932a685d8919f288bfa5a136c3d082cc387 Mon Sep 17 00:00:00 2001 From: Rajkumar Rangaraj Date: Thu, 19 Sep 2024 17:32:10 -0700 Subject: [PATCH] [repo] Replace .NET6 target with .NET9 (#5832) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Mikel Blanchard Co-authored-by: Piotr Kiełkowicz --- .editorconfig | 38 ++++++++++--------- .github/ISSUE_TEMPLATE/bug_report.yml | 2 +- .github/workflows/Component.BuildTest.yml | 4 +- .github/workflows/ci.yml | 4 +- .github/workflows/docfx.yml | 3 ++ .github/workflows/verifyaotcompat.yml | 2 +- CONTRIBUTING.md | 2 +- Directory.Packages.props | 6 +-- OpenTelemetry.sln | 2 +- build/Common.nonprod.props | 2 +- build/Common.prod.props | 7 ++++ build/Common.props | 14 +++---- build/docker-compose.net6.0.yml | 9 ----- build/docker-compose.net8.0.yml | 2 +- build/docker-compose.net9.0.yml | 9 +++++ global.json | 2 +- .../Internal/SelfDiagnosticsConfigParser.cs | 4 +- .../Dockerfile | 6 +-- .../SelfDiagnosticsEventListenerTest.cs | 8 +++- 19 files changed, 73 insertions(+), 53 deletions(-) delete mode 100644 build/docker-compose.net6.0.yml create mode 100644 build/docker-compose.net9.0.yml diff --git a/.editorconfig b/.editorconfig index 5bc89604c76..45d0806a20b 100644 --- a/.editorconfig +++ b/.editorconfig @@ -41,7 +41,7 @@ csharp_indent_labels = flush_left # Modifier preferences 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 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_when_type_is_apparent = true:silent csharp_style_var_elsewhere = true:silent -dotnet_style_predefined_type_for_locals_parameters_members = true:silent -dotnet_style_predefined_type_for_member_access = true:silent +dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion +dotnet_style_predefined_type_for_member_access = true:suggestion # name all constant fields using PascalCase 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 dotnet_style_prefer_simplified_interpolation = true:suggestion dotnet_style_object_initializer = true:suggestion +csharp_style_prefer_primary_constructors = false:none # Expression-level preferences 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_coalesce_expression = 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_anonymous_type_member_names = true:suggestion -dotnet_style_prefer_auto_properties = true:silent -dotnet_style_prefer_conditional_expression_over_assignment = true:silent -dotnet_style_prefer_conditional_expression_over_return = true:silent +dotnet_style_prefer_auto_properties = true:suggestion +dotnet_style_prefer_conditional_expression_over_assignment = true:suggestion +dotnet_style_prefer_conditional_expression_over_return = true:suggestion csharp_prefer_simple_default_expression = true:suggestion +csharp_style_unused_value_expression_statement_preference = discard_variable:none # Expression-bodied members -csharp_style_expression_bodied_methods = false:silent -csharp_style_expression_bodied_constructors = false:silent -csharp_style_expression_bodied_operators = false:silent -csharp_style_expression_bodied_properties = true:silent -csharp_style_expression_bodied_indexers = true:silent -csharp_style_expression_bodied_accessors = true:silent +csharp_style_expression_bodied_methods = true:suggestion +dotnet_diagnostic.IDE0022.severity = suggestion # dotnet format doesn't respect the suggestion in the line above +csharp_style_expression_bodied_constructors = false:warning +csharp_style_expression_bodied_operators = true:suggestion +csharp_style_expression_bodied_properties = true:suggestion +csharp_style_expression_bodied_indexers = true:suggestion +csharp_style_expression_bodied_accessors = true:suggestion # Pattern matching 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_deconstructed_variable_declaration = true:suggestion csharp_style_namespace_declarations = file_scoped:warning +dotnet_style_namespace_match_folder = false:none # Space preferences csharp_space_after_cast = false @@ -128,10 +132,10 @@ csharp_space_between_method_declaration_parameter_list_parentheses = false csharp_space_between_parentheses = false # Parentheses preferences -dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:silent -dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:silent -dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:silent -dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent +dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:suggestion +dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:suggestion +dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:suggestion +dotnet_style_parentheses_in_other_operators = never_if_unnecessary:suggestion # Code analyzers # CA1031: Do not catch general exception types diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index baef921968e..d503e982d1f 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -48,7 +48,7 @@ body: - type: input attributes: 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: required: true diff --git a/.github/workflows/Component.BuildTest.yml b/.github/workflows/Component.BuildTest.yml index e25352b0854..de7ebb3fc4f 100644 --- a/.github/workflows/Component.BuildTest.yml +++ b/.github/workflows/Component.BuildTest.yml @@ -24,7 +24,7 @@ on: required: false type: string tfm-list: - default: '[ "net462", "net6.0", "net8.0" ]' + default: '[ "net462", "net8.0", "net9.0" ]' required: false type: string @@ -42,7 +42,7 @@ jobs: - os: otel-linux-arm64 version: net462 - os: otel-linux-arm64 - version: net6.0 + version: net8.0 runs-on: ${{ matrix.os }} steps: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 58eef737fca..73ecbd165ea 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -111,7 +111,7 @@ jobs: strategy: fail-fast: false matrix: - version: [ net6.0, net8.0 ] + version: [ net8.0, net9.0 ] steps: - uses: actions/checkout@v4 - name: Run OTLP Exporter docker compose @@ -129,7 +129,7 @@ jobs: strategy: fail-fast: false matrix: - version: [ net6.0, net8.0 ] + version: [ net8.0, net9.0 ] steps: - uses: actions/checkout@v4 - name: Run W3C Trace Context docker compose diff --git a/.github/workflows/docfx.yml b/.github/workflows/docfx.yml index 4c2031c9303..76ab4f2e1ec 100644 --- a/.github/workflows/docfx.yml +++ b/.github/workflows/docfx.yml @@ -13,6 +13,9 @@ jobs: - name: check out code uses: actions/checkout@v4 + - name: Setup dotnet + uses: actions/setup-dotnet@v4 + - name: install docfx run: dotnet tool install -g docfx diff --git a/.github/workflows/verifyaotcompat.yml b/.github/workflows/verifyaotcompat.yml index 24991b9fe3c..3bdc42e3e7f 100644 --- a/.github/workflows/verifyaotcompat.yml +++ b/.github/workflows/verifyaotcompat.yml @@ -12,7 +12,7 @@ jobs: fail-fast: false # ensures the entire test matrix is run, even if one permutation fails matrix: os: [ ubuntu-latest, windows-latest ] - version: [ net8.0 ] + version: [ net8.0, net9.0 ] runs-on: ${{ matrix.os }} steps: diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index fda1c81c336..c6b0e6c4fe6 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -44,7 +44,7 @@ You can contribute to this project from a Windows, macOS or Linux machine. On all platforms, the minimum requirements are: * Git client and command line tools. -* .NET 8.0 +* .NET 9.0 ### Linux or MacOS diff --git a/Directory.Packages.props b/Directory.Packages.props index abe3785ad8d..f54bd7353a3 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -97,10 +97,10 @@ - - - + + + diff --git a/OpenTelemetry.sln b/OpenTelemetry.sln index 2cfcf9b1f22..5ca42dd0962 100644 --- a/OpenTelemetry.sln +++ b/OpenTelemetry.sln @@ -31,8 +31,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{7CB2F02E build\debug.snk = build\debug.snk Directory.Packages.props = Directory.Packages.props 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.net9.0.yml = build\docker-compose.net9.0.yml build\GlobalAttrExclusions.txt = build\GlobalAttrExclusions.txt build\opentelemetry-icon-color.png = build\opentelemetry-icon-color.png build\OpenTelemetry.prod.loose.ruleset = build\OpenTelemetry.prod.loose.ruleset diff --git a/build/Common.nonprod.props b/build/Common.nonprod.props index 6de6e014c88..ce99895ccba 100644 --- a/build/Common.nonprod.props +++ b/build/Common.nonprod.props @@ -8,7 +8,7 @@ - net8.0 + net9.0 diff --git a/build/Common.prod.props b/build/Common.prod.props index 9f2c78486c3..1b58605b4d1 100644 --- a/build/Common.prod.props +++ b/build/Common.prod.props @@ -33,6 +33,13 @@ true + + + + + diff --git a/build/Common.props b/build/Common.props index 7c1f02bdebf..54ecbacfe9b 100644 --- a/build/Common.props +++ b/build/Common.props @@ -28,18 +28,18 @@ net481;net48;net472;net471;net47;net462 - net8.0;net6.0;netstandard2.0;$(NetFrameworkMinimumSupportedVersion) - net8.0;net6.0;netstandard2.1;netstandard2.0;$(NetFrameworkMinimumSupportedVersion) - net8.0;net6.0 + net9.0;net8.0;netstandard2.0;$(NetFrameworkMinimumSupportedVersion) + net9.0;net8.0;netstandard2.1;netstandard2.0;$(NetFrameworkMinimumSupportedVersion) + net9.0;net8.0 - net8.0;net6.0 - net8.0 - net8.0;net6.0 + net9.0;net8.0 + net9.0;net8.0 + net9.0;net8.0 $(TargetFrameworksForDocs);$(NetFrameworkSupportedVersions) - net8.0;net6.0 + net9.0;net8.0 $(TargetFrameworksForTests);$(NetFrameworkMinimumSupportedVersion) diff --git a/build/docker-compose.net6.0.yml b/build/docker-compose.net6.0.yml deleted file mode 100644 index 099f1007277..00000000000 --- a/build/docker-compose.net6.0.yml +++ /dev/null @@ -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" diff --git a/build/docker-compose.net8.0.yml b/build/docker-compose.net8.0.yml index a5ac999e43e..22787bff66e 100644 --- a/build/docker-compose.net8.0.yml +++ b/build/docker-compose.net8.0.yml @@ -6,4 +6,4 @@ services: args: PUBLISH_FRAMEWORK: net8.0 TEST_SDK_VERSION: "8.0" - BUILD_SDK_VERSION: "8.0" + BUILD_SDK_VERSION: "9.0" diff --git a/build/docker-compose.net9.0.yml b/build/docker-compose.net9.0.yml new file mode 100644 index 00000000000..29663b3246c --- /dev/null +++ b/build/docker-compose.net9.0.yml @@ -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" diff --git a/global.json b/global.json index 0aca8b12938..f459bbb82e4 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { "rollForward": "latestFeature", - "version": "8.0.100" + "version": "9.0.100-rc.1.24452.12" } } diff --git a/src/OpenTelemetry/Internal/SelfDiagnosticsConfigParser.cs b/src/OpenTelemetry/Internal/SelfDiagnosticsConfigParser.cs index 3216c050f7c..751154f8849 100644 --- a/src/OpenTelemetry/Internal/SelfDiagnosticsConfigParser.cs +++ b/src/OpenTelemetry/Internal/SelfDiagnosticsConfigParser.cs @@ -66,7 +66,9 @@ public bool TryGetConfiguration( 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); if (!TryParseLogDirectory(configJson, out logDirectory)) diff --git a/test/OpenTelemetry.Instrumentation.W3cTraceContext.Tests/Dockerfile b/test/OpenTelemetry.Instrumentation.W3cTraceContext.Tests/Dockerfile index 7a8dc6f5705..fc50a196ecf 100644 --- a/test/OpenTelemetry.Instrumentation.W3cTraceContext.Tests/Dockerfile +++ b/test/OpenTelemetry.Instrumentation.W3cTraceContext.Tests/Dockerfile @@ -2,8 +2,8 @@ # This should be run from the root of the repo: # docker build --file test/OpenTelemetry.Instrumentation.W3cTraceContext.Tests/Dockerfile . -ARG BUILD_SDK_VERSION=8.0 -ARG TEST_SDK_VERSION=8.0 +ARG BUILD_SDK_VERSION=9.0 +ARG TEST_SDK_VERSION=9.0 FROM ubuntu AS w3c #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 ARG PUBLISH_CONFIGURATION=Release -ARG PUBLISH_FRAMEWORK=net8.0 +ARG PUBLISH_FRAMEWORK=net9.0 WORKDIR /repo COPY . ./ WORKDIR "/repo/test/OpenTelemetry.Instrumentation.W3cTraceContext.Tests" diff --git a/test/OpenTelemetry.Tests/Internal/SelfDiagnosticsEventListenerTest.cs b/test/OpenTelemetry.Tests/Internal/SelfDiagnosticsEventListenerTest.cs index 58777971b5d..3ea7ae3bf7a 100644 --- a/test/OpenTelemetry.Tests/Internal/SelfDiagnosticsEventListenerTest.cs +++ b/test/OpenTelemetry.Tests/Internal/SelfDiagnosticsEventListenerTest.cs @@ -124,7 +124,9 @@ public void SelfDiagnosticsEventListener_EmitEvent_OmitAsConfigured() using FileStream file = File.Open(LOGFILEPATH, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete); 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]); } @@ -256,7 +258,9 @@ private static void AssertFileOutput(string filePath, string eventMessage) { using FileStream file = File.Open(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete); 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 logMessage = ParseLogMessage(logLine); Assert.StartsWith(eventMessage, logMessage);