Skip to content

Commit

Permalink
Merge branch 'main' into yunl/ns2
Browse files Browse the repository at this point in the history
  • Loading branch information
cijothomas authored Aug 5, 2022
2 parents 2f41181 + 668b073 commit 17e5fb9
Show file tree
Hide file tree
Showing 19 changed files with 20 additions and 42 deletions.
1 change: 1 addition & 0 deletions .github/workflows/dotnet-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jobs:
uses: actions/setup-dotnet@v2
with:
dotnet-version: '7.0.x'
include-prerelease: true

- name: Install format tool
run: dotnet tool install -g dotnet-format
Expand Down
2 changes: 1 addition & 1 deletion src/OpenTelemetry.Api/Internal/Guard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
using System.Runtime.CompilerServices;
using System.Threading;

#if !NETCOREAPP3_0_OR_GREATER
#if !NET6_0_OR_GREATER
namespace System.Runtime.CompilerServices
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public PrometheusCollectionManager(PrometheusExporter exporter)
this.onCollectRef = this.OnCollect;
}

#if NETCOREAPP3_1_OR_GREATER
#if NET6_0_OR_GREATER
public ValueTask<CollectionResponse> EnterCollect()
#else
public Task<CollectionResponse> EnterCollect()
Expand All @@ -58,7 +58,7 @@ public Task<CollectionResponse> EnterCollect()
{
Interlocked.Increment(ref this.readerCount);
this.ExitGlobalLock();
#if NETCOREAPP3_1_OR_GREATER
#if NET6_0_OR_GREATER
return new ValueTask<CollectionResponse>(new CollectionResponse(this.previousDataView, this.previousDataViewGeneratedAtUtc.Value, fromCache: true));
#else
return Task.FromResult(new CollectionResponse(this.previousDataView, this.previousDataViewGeneratedAtUtc.Value, fromCache: true));
Expand All @@ -75,7 +75,7 @@ public Task<CollectionResponse> EnterCollect()

Interlocked.Increment(ref this.readerCount);
this.ExitGlobalLock();
#if NETCOREAPP3_1_OR_GREATER
#if NET6_0_OR_GREATER
return new ValueTask<CollectionResponse>(this.collectionTcs.Task);
#else
return this.collectionTcs.Task;
Expand Down Expand Up @@ -114,7 +114,7 @@ public Task<CollectionResponse> EnterCollect()

this.ExitGlobalLock();

#if NETCOREAPP3_1_OR_GREATER
#if NET6_0_OR_GREATER
return new ValueTask<CollectionResponse>(response);
#else
return Task.FromResult(response);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// limitations under the License.
// </copyright>

#if NETCOREAPP3_1_OR_GREATER
#if NET6_0_OR_GREATER
using System;
#endif
using System.Diagnostics;
Expand Down Expand Up @@ -42,7 +42,7 @@ public static int WriteDouble(byte[] buffer, int cursor, double value)
{
if (MathHelper.IsFinite(value))
{
#if NETCOREAPP3_1_OR_GREATER
#if NET6_0_OR_GREATER
Span<char> span = stackalloc char[128];

var result = value.TryFormat(span, out var cchWritten, "G", CultureInfo.InvariantCulture);
Expand Down Expand Up @@ -76,7 +76,7 @@ public static int WriteDouble(byte[] buffer, int cursor, double value)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static int WriteLong(byte[] buffer, int cursor, long value)
{
#if NETCOREAPP3_1_OR_GREATER
#if NET6_0_OR_GREATER
Span<char> span = stackalloc char[20];

var result = value.TryFormat(span, out var cchWritten, "G", CultureInfo.InvariantCulture);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public class AspNetCoreInstrumentationOptions
/// </remarks>
public bool RecordException { get; set; }

#if NETSTANDARD2_1 || NETCOREAPP3_1 || NET6_0_OR_GREATER
#if NETSTANDARD2_1 || NET6_0_OR_GREATER
/// <summary>
/// Gets or sets a value indicating whether RPC attributes are added to an Activity when using Grpc.AspNetCore. Default is true.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ private static string GetUri(HttpRequest request)
var queryString = request.QueryString.Value ?? string.Empty;
var length = scheme.Length + Uri.SchemeDelimiter.Length + host.Length + pathBase.Length
+ path.Length + queryString.Length;
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
#if NETSTANDARD2_1_OR_GREATER || NET6_0_OR_GREATER
return string.Create(length, (scheme, host, pathBase, path, queryString), (span, parts) =>
{
CopyTo(ref span, parts.scheme);
Expand Down
2 changes: 1 addition & 1 deletion src/OpenTelemetry/Internal/MathHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public static long PositiveModulo64(long value, long divisor)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool IsFinite(double value)
{
#if NETCOREAPP3_1_OR_GREATER
#if NET6_0_OR_GREATER
return double.IsFinite(value);
#else
return !double.IsInfinity(value) && !double.IsNaN(value);
Expand Down
4 changes: 2 additions & 2 deletions src/OpenTelemetry/Internal/ServiceProviderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// limitations under the License.
// </copyright>

#if NETFRAMEWORK || NETSTANDARD2_0_OR_GREATER || NETCOREAPP3_1_OR_GREATER
#if NETFRAMEWORK || NETSTANDARD2_0_OR_GREATER || NET6_0_OR_GREATER
using Microsoft.Extensions.Options;
#endif

Expand All @@ -34,7 +34,7 @@ internal static class ServiceProviderExtensions
public static T GetOptions<T>(this IServiceProvider serviceProvider)
where T : class, new()
{
#if NETFRAMEWORK || NETSTANDARD2_0_OR_GREATER || NETCOREAPP3_1_OR_GREATER
#if NETFRAMEWORK || NETSTANDARD2_0_OR_GREATER || NET6_0_OR_GREATER
IOptions<T> options = (IOptions<T>)serviceProvider.GetService(typeof(IOptions<T>));

// Note: options could be null if user never invoked services.AddOptions().
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// limitations under the License.
// </copyright>

#if NETCOREAPP3_1_OR_GREATER
#if NET6_0_OR_GREATER

using System;
using System.Collections.Generic;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,4 @@
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="6.0.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="3.1.0" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@
using OpenTelemetry.Tests;
using OpenTelemetry.Trace;

#if NETCOREAPP3_1
using TestApp.AspNetCore._3._1;
#endif
#if NET6_0
using TestApp.AspNetCore._6._0;
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@
using Microsoft.AspNetCore.TestHost;
using Microsoft.Extensions.DependencyInjection;
using OpenTelemetry.Trace;
#if NETCOREAPP3_1
using TestApp.AspNetCore._3._1;
#endif
#if NET6_0
using TestApp.AspNetCore._6._0;
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@
using Microsoft.AspNetCore.TestHost;
using Microsoft.Extensions.DependencyInjection;
using OpenTelemetry.Trace;
#if NETCOREAPP3_1
using TestApp.AspNetCore._3._1;
#endif
#if NET6_0
using TestApp.AspNetCore._6._0;
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@
using Microsoft.AspNetCore.Mvc.Testing;
using OpenTelemetry.Metrics;
using OpenTelemetry.Trace;
#if NETCOREAPP3_1
using TestApp.AspNetCore._3._1;
#endif
#if NET6_0
using TestApp.AspNetCore._6._0;
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,4 @@
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="6.0.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
<ProjectReference Include="$(RepoRoot)\test\TestApp.AspNetCore.3.1\TestApp.AspNetCore.3.1.csproj" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="3.0.0" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// <copyright file="HttpClientTests.Basic.netcore31.cs" company="OpenTelemetry Authors">
// <copyright file="HttpClientTests.Basic.cs" company="OpenTelemetry Authors">
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -13,7 +13,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
// </copyright>
#if NETCOREAPP3_1_OR_GREATER
#if !NETFRAMEWORK
using System;
using System.Diagnostics;
using System.Linq;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// <copyright file="HttpClientTests.netcore31.cs" company="OpenTelemetry Authors">
// <copyright file="HttpClientTests.cs" company="OpenTelemetry Authors">
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -13,7 +13,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
// </copyright>
#if NETCOREAPP3_1_OR_GREATER
#if !NETFRAMEWORK
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using OpenTelemetry.Trace;
#if NETCOREAPP3_1
using TestApp.AspNetCore._3._1;
#endif
#if NET6_0
using TestApp.AspNetCore._6._0;
#endif
Expand Down
2 changes: 1 addition & 1 deletion test/OpenTelemetry.Tests/Internal/GuardTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public class Thing
public string Bar { get; set; }
}

#if !NETCOREAPP3_0_OR_GREATER
#if !NET6_0_OR_GREATER
/// <summary>
/// Borrowed from: <see href="https://github.com/dotnet/runtime/blob/main/src/libraries/System.Runtime/tests/System/Runtime/CompilerServices/CallerArgumentExpressionAttributeTests.cs"/>.
/// </summary>
Expand Down

0 comments on commit 17e5fb9

Please sign in to comment.