Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable .net6.0 build and add net6.0 target #2559

Merged

Conversation

vishweshbankwar
Copy link
Member

@vishweshbankwar vishweshbankwar commented Nov 2, 2021

Fixes #.
2064

Changes

Please provide a brief description of the changes here.

  1. Add .NET6.0 build
  2. Add .NET6.0 target to test projects and aspnetcore instrumentation library

todos

  1. Replace RC package version to GA versions once available.
  2. Remove explicit install for .NET SDKs once 6.0 is available as pre-installed.

For significant contributions please make sure you have completed the following items:

  • CHANGELOG.md updated for non-trivial changes
  • Design discussion issue #
  • Changes in public API reviewed

@codecov
Copy link

codecov bot commented Nov 2, 2021

Codecov Report

Merging #2559 (80f27e7) into main (02f2594) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #2559   +/-   ##
=======================================
  Coverage   80.84%   80.84%           
=======================================
  Files         254      254           
  Lines        8552     8552           
=======================================
  Hits         6914     6914           
  Misses       1638     1638           
Impacted Files Coverage Δ
...ion.AspNetCore/AspNetCoreInstrumentationOptions.cs 100.00% <ø> (ø)
...emetry.Api/Internal/OpenTelemetryApiEventSource.cs 79.41% <0.00%> (-2.95%) ⬇️
...cSourceInstrumentation/DiagnosticSourceListener.cs 80.00% <0.00%> (+5.00%) ⬆️

@vishweshbankwar vishweshbankwar changed the title Enable .net6.0 build Enable .net6.0 build and add net6.0 target Nov 3, 2021
@vishweshbankwar vishweshbankwar marked this pull request as ready for review November 3, 2021 22:33
@vishweshbankwar vishweshbankwar requested a review from a team November 3, 2021 22:33
@reyang
Copy link
Member

reyang commented Nov 4, 2021

(no need to make the change in this PR)

It seems most of the test projects are using the same target frameworks netcoreapp3.1;net5.0;net6.0, might be good to extract the logic to a common place like

<TargetFrameworks>netcoreapp3.1;net5.0</TargetFrameworks>
.

@@ -26,6 +26,19 @@ jobs:
with:
fetch-depth: 0 # fetching all

- uses: actions/setup-dotnet@v1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't need to install 3.1.x/5.0.x because they are already installed in windows-latest. I always check this:

Remember that windows-latest can change in the future to windows-2022, so, always have that in mind.

steps:
- uses: actions/checkout@v2

- uses: actions/setup-dotnet@v1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comment as above, no need for 3.1.x or 5.0.x

steps:
- uses: actions/checkout@v2

- uses: actions/setup-dotnet@v1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here as well :)

steps:
- uses: actions/checkout@v2

- uses: actions/setup-dotnet@v1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here as well

steps:
- uses: actions/checkout@v2

- uses: actions/setup-dotnet@v1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


steps:
- uses: actions/checkout@v2

- uses: actions/setup-dotnet@v1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


steps:
- uses: actions/checkout@v2

- uses: actions/setup-dotnet@v1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

using Microsoft.AspNetCore.Mvc;
using OpenTelemetry;

namespace TestApp.AspNetCore._6._0.Controllers
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one day, we have to figure out how to prevent this code over and over.
we already have the "same" code for 3.1, 5.0, 6.0

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vishweshbankwar
Copy link
Member Author

(no need to make the change in this PR)

It seems most of the test projects are using the same target frameworks netcoreapp3.1;net5.0;net6.0, might be good to extract the logic to a common place like

<TargetFrameworks>netcoreapp3.1;net5.0</TargetFrameworks>

.

Yes - I was thinking the same. will look in to creating a separate PR for this.

@cijothomas cijothomas merged commit 4f930d5 into open-telemetry:main Nov 4, 2021
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard2.1;netcoreapp3.1;net5.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;netstandard2.1;netcoreapp3.1;net5.0;net6.0</TargetFrameworks>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious, why was this needed?

Copy link
Member Author

@vishweshbankwar vishweshbankwar Nov 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we are using FrameworkReference, this is needed.
IIRC, if we do not add this, net5.0 targeted instrumentation library will be used for net6.0 app (should still work as we don't have any NET6 framework specific code).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it is needed until we want to use some piece of the .NET 6 API.

If the project is like this...

<TargetFrameworks>netstandard2.0;netstandard2.1;netcoreapp3.1;net5.0</TargetFrameworks>

  <ItemGroup Condition="'$(TargetFramework)' == 'net5.0'">
    <FrameworkReference Include="Microsoft.AspNetCore.App" />
  </ItemGroup>

Users on .NET 6 will still be able to use it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed - then do we remove 5.0 as well?. I have not tested but I think having only 3.1 will also work for 3.1+ apps then?.
But if we ever use version specific code, we will have to do add it again.
@cijothomas - thoughts?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't use any .NET 6 specific feature today, but Asp.Net core 6.0 has introduced ActivitySource usage. If we want to leverage them, we either need .net6.0 target. or we use reflection to find if user is running Asp.Net Core 6.0 or newer.
(@vishweshbankwar please create a separate issue to discuss this further)

@@ -52,7 +52,7 @@ public class AspNetCoreInstrumentationOptions
/// </remarks>
public bool RecordException { get; set; }

#if NETSTANDARD2_1 || NETCOREAPP3_1 || NET5_0
#if NETSTANDARD2_1 || NETCOREAPP3_1 || NET5_0_OR_GREATER
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be only:

#if NETSTANDARD2_1 || NETCOREAPP3_1_OR_GREATER

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason why we probably used #if NETSTANDARD2_1 || NETCOREAPP3_1 || NET5_0 in the first place
https://docs.microsoft.com/en-us/dotnet/core/compatibility/sdk/5.0/netcoreapp3_1-preprocessor-symbol-not-defined

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That affects .net 5 SDK, right? So now on NET6 it should work if I undersand?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it looks like it from the .NET 5 and later bullet here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants