Skip to content

Commit

Permalink
Add support for net462
Browse files Browse the repository at this point in the history
  • Loading branch information
jon-armen committed Apr 20, 2022
1 parent d4773aa commit ffcbf99
Show file tree
Hide file tree
Showing 38 changed files with 143 additions and 283 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
strategy:
fail-fast: false
matrix:
version: [net452, netcoreapp2.0, netcoreapp3.1]
version: [net452, net462, netcoreapp2.0, netcoreapp3.1]

steps:
- name: Checkout repository
Expand Down
2 changes: 1 addition & 1 deletion sdk/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
</ItemGroup>

<!-- NetFramework does not support embedded pdb -->
<PropertyGroup Condition="'$(TargetFramework)' == 'net45' or '$(TargetFramework)' == 'net452'">
<PropertyGroup Condition="'$(TargetFramework)' == 'net45' or '$(TargetFramework)' == 'net452' or '$(TargetFramework)' == 'net462'">
<DebugType>portable</DebugType>
</PropertyGroup>
</Project>
14 changes: 7 additions & 7 deletions sdk/src/Core/AWSXRayRecorder.Core.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net45;netstandard2.0;netcoreapp3.1</TargetFrameworks>
<TargetFrameworks>net45;net462;netstandard2.0;netcoreapp3.1</TargetFrameworks>
<Company>Amazon.com, Inc</Company>
<Product>Amazon Web Service X-Ray Recorder</Product>
<Copyright>Copyright 2017-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.</Copyright>
Expand Down Expand Up @@ -47,14 +47,14 @@
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' != 'net45'">
<Compile Remove="Internal\Context\CallContextContainer.net45.cs" />
<Compile Remove="Internal\Context\HybridContextContainer.net45.cs" />
<Compile Remove="Internal\Utils\AppSettings.net45.cs" />
<ItemGroup Condition="'$(TargetFramework)' != 'net45' AND '$(TargetFramework)' != 'net462'">
<Compile Remove="Internal\Context\CallContextContainer.netframework.cs" />
<Compile Remove="Internal\Context\HybridContextContainer.netframework.cs" />
<Compile Remove="Internal\Utils\AppSettings.netframework.cs" />
<Compile Remove="AWSXRayRecorder.cs" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net45'">
<ItemGroup Condition="'$(TargetFramework)' == 'net45' OR '$(TargetFramework)' == 'net462'">
<Compile Remove="Internal\Context\AsyncLocalContextContainer.netstandard.cs" />
<Compile Remove="Internal\Context\LambdaContextContainer.netstandard.cs" />
<Compile Remove="Internal\Utils\AppSettings.netcore.cs" />
Expand All @@ -63,7 +63,7 @@
<Compile Remove="FacadeSegment.cs" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net45'">
<ItemGroup Condition="'$(TargetFramework)' == 'net45' OR '$(TargetFramework)' == 'net462'">
<Reference Include="System.Configuration" />
<Reference Include="System.Web" />
<Reference Include="System.Net.Http" />
Expand Down
10 changes: 5 additions & 5 deletions sdk/src/Core/AWSXRayRecorderImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ namespace Amazon.XRay.Recorder.Core
public abstract class AWSXRayRecorderImpl : IAWSXRayRecorder
{
private static readonly Logger _logger = Logger.GetLogger(typeof(AWSXRayRecorderImpl));
#if NET45
#if NETFRAMEWORK
private static Lazy<AWSXRayRecorder> _lazyDefaultRecorder = new Lazy<AWSXRayRecorder>(() => AWSXRayRecorderBuilder.GetDefaultBuilder().Build());
protected static Lazy<AWSXRayRecorder> LazyDefaultRecorder
{
Expand Down Expand Up @@ -151,7 +151,7 @@ public ContextMissingStrategy ContextMissingStrategy
/// <exception cref="ArgumentNullException">The argument has a null value.</exception>
public void BeginSegment(string name, string traceId = null, string parentId = null, SamplingResponse samplingResponse = null, DateTime? timestamp = null)
{
#if !NET45
#if !NETFRAMEWORK
if (AWSXRayRecorder.IsLambda())
{
throw new UnsupportedOperationException("Cannot override Facade Segment. New segment not created.");
Expand Down Expand Up @@ -193,7 +193,7 @@ public void BeginSegment(string name, string traceId = null, string parentId = n
/// <exception cref="EntityNotAvailableException">Entity is not available in trace context.</exception>
public void EndSegment(DateTime? timestamp = null)
{
#if !NET45
#if !NETFRAMEWORK
if (AWSXRayRecorder.IsLambda())
{
throw new UnsupportedOperationException("Cannot override Facade Segment. New segment not created.");
Expand Down Expand Up @@ -728,7 +728,7 @@ protected void PopulateContexts()
// Prepare XRay section for runtime context
var xrayContext = new ConcurrentDictionary<string, string>();

#if NET45
#if NETFRAMEWORK
xrayContext["sdk"] = "X-Ray for .NET";
#else
xrayContext["sdk"] = "X-Ray for .NET Core";
Expand All @@ -744,7 +744,7 @@ protected void PopulateContexts()
}

RuntimeContext["xray"] = xrayContext;
#if NET45
#if NETFRAMEWORK
ServiceContext["runtime"] = ".NET Framework";
#else
ServiceContext["runtime"] = ".NET Core Framework";
Expand Down
4 changes: 2 additions & 2 deletions sdk/src/Core/AwsXrayRecorderBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public IReadOnlyList<IPlugin> Plugins
}
}

#if NET45
#if NETFRAMEWORK
/// <summary>
/// Initializes <see cref="AWSXRayRecorderBuilder"/> instance with default settings.
/// </summary>
Expand All @@ -67,7 +67,7 @@ public static AWSXRayRecorderBuilder GetDefaultBuilder()
}
#endif

#if NET45
#if NETFRAMEWORK
/// <summary>
/// Reads plugin settings from app settings, and adds new instance of each plugin into the builder.
/// If the plugin settings doesn't exist or the value of the settings is invalid, nothing will be added.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//-----------------------------------------------------------------------------
// <copyright file="CallContextContainer.net45.cs" company="Amazon.com">
// <copyright file="CallContextContainer.netframework.cs" company="Amazon.com">
// Copyright 2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License").
Expand Down
2 changes: 1 addition & 1 deletion sdk/src/Core/Internal/Context/DefaultTraceContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public static class DefaultTraceContext
/// <returns>default instance of <see cref="ITraceContext"/></returns>
public static ITraceContext GetTraceContext()
{
#if NET45
#if NETFRAMEWORK
return new CallContextContainer();
#else
if (AWSXRayRecorder.IsLambda())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//-----------------------------------------------------------------------------
// <copyright file="TraceContext.net45.cs" company="Amazon.com">
// <copyright file="TraceContext.netframework.cs" company="Amazon.com">
// Copyright 2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License").
Expand Down
4 changes: 2 additions & 2 deletions sdk/src/Core/Strategies/DynamicSegmentNamingStrategy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
using System.Text.RegularExpressions;
using Amazon.Runtime.Internal.Util;
using Amazon.XRay.Recorder.Core.Internal.Utils;
#if NET45
#if NETFRAMEWORK
using System.Net.Http;
#else
using Microsoft.AspNetCore.Http;
Expand Down Expand Up @@ -81,7 +81,7 @@ public DynamicSegmentNamingStrategy(string fallbackSegmentName, string hostNameP
/// </summary>
public string FallbackSegmentName { get; set; }

#if NET45
#if NETFRAMEWORK
/// <summary>
/// Gets the name of the segment.
/// </summary>
Expand Down
4 changes: 2 additions & 2 deletions sdk/src/Core/Strategies/FixedSegmentNamingStrategy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
using System;

using Amazon.Runtime.Internal.Util;
#if NET45
#if NETFRAMEWORK
using System.Net.Http;
#else
using Microsoft.AspNetCore.Http;
Expand Down Expand Up @@ -61,7 +61,7 @@ public FixedSegmentNamingStrategy(string fixedName)
/// </summary>
public string FixedName { get; set; }

#if NET45
#if NETFRAMEWORK
/// <summary>
/// Gets the name of the segment.
/// </summary>
Expand Down
4 changes: 2 additions & 2 deletions sdk/src/Core/Strategies/SegmentNamingStrategy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

using System;

#if NET45
#if NETFRAMEWORK
using System.Net.Http;
#else
using Microsoft.AspNetCore.Http;
Expand Down Expand Up @@ -46,7 +46,7 @@ public static string GetSegmentNameFromEnvironmentVariable()
return Environment.GetEnvironmentVariable(SegmentNamingStrategy.EnvironmentVariableSegmentName);
}

#if NET45
#if NETFRAMEWORK
/// <summary>
/// Gets the name of the segment.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net45</TargetFrameworks>
<TargetFrameworks>net45;net462</TargetFrameworks>
<Company>Amazon.com, Inc</Company>
<Product>Amazon Web Service X-Ray Recorder</Product>
<Copyright>Copyright 2017-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.</Copyright>
Expand All @@ -25,10 +25,6 @@
<ProjectReference Include="..\..\Core\AWSXRayRecorder.Core.csproj" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net45'">
<Reference Include="Microsoft.CSharp" />
</ItemGroup>

<ItemGroup>
<Reference Include="System.Web" />
<Reference Include="System.Net.Http" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net45;netstandard2.0</TargetFrameworks>
<TargetFrameworks>net45;net462;netstandard2.0</TargetFrameworks>
<Company>Amazon.com, Inc</Company>
<Product>Amazon Web Service X-Ray Recorder</Product>
<Copyright>Copyright 2017-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.</Copyright>
Expand Down Expand Up @@ -33,7 +33,7 @@
<EmbeddedResource Include="DefaultAWSWhitelist.json" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' != 'net45'">
<ItemGroup Condition="'$(TargetFramework)' != 'net45' AND '$(TargetFramework)' != 'net462'">
<Compile Remove="AWSSdkTracingHandler.cs" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net45;netstandard2.0</TargetFrameworks>
<TargetFrameworks>net45;net462;netstandard2.0</TargetFrameworks>
<Company>Amazon.com, Inc</Company>
<Product>Amazon Web Service X-Ray Recorder</Product>
<Copyright>Copyright 2017-2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.</Copyright>
Expand All @@ -25,10 +25,10 @@
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="3.1.0" />
<Compile Remove="AWSXRayEntityFramework6.cs" />
<Compile Remove="EFInterceptor.net45.cs" />
<Compile Remove="EFInterceptor.netframework.cs" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net45'">
<ItemGroup Condition="'$(TargetFramework)' == 'net45' OR '$(TargetFramework)' == 'net462'">
<PackageReference Include="EntityFramework" Version="6.2.0" />
<Compile Remove="AWSXRayInterceptorExtensions.cs" />
<Compile Remove="EFInterceptor.cs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//-----------------------------------------------------------------------------
// <copyright file="EFInterceptor.net45.cs" company="Amazon.com">
// <copyright file="EFInterceptor.netframework.cs" company="Amazon.com">
// Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License").
Expand Down
4 changes: 2 additions & 2 deletions sdk/src/Handlers/EntityFramework/EFUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
using System.Text.RegularExpressions;
using Amazon.Runtime.Internal.Util;
using Amazon.XRay.Recorder.Core;
#if NET45
#if NETFRAMEWORK
using Amazon.XRay.Recorder.Core.Internal.Utils;
#endif

Expand Down Expand Up @@ -191,7 +191,7 @@ private static string RemovePortNumberFromDataSource(string dataSource)
return _portNumberRegex.Replace(dataSource, string.Empty);
}

#if !NET45
#if !NETFRAMEWORK
private static bool ShouldCollectSqlText(bool? collectSqlQueriesOverride)
=> collectSqlQueriesOverride ?? _recorder.XRayOptions.CollectSqlQueries;
#else
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net45;netstandard2.0</TargetFrameworks>
<TargetFrameworks>net45;net462;netstandard2.0</TargetFrameworks>
<Company>Amazon.com, Inc</Company>
<Product>Amazon Web Service X-Ray Recorder</Product>
<Copyright>Copyright 2017-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.</Copyright>
Expand Down Expand Up @@ -29,8 +29,8 @@
<ProjectReference Include="..\..\Core\AWSXRayRecorder.Core.csproj" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' != 'net45'">
<Compile Remove="TraceableSqlCommand.net45.cs" />
<ItemGroup Condition="'$(TargetFramework)' != 'net45' AND '$(TargetFramework)' != 'net462'">
<Compile Remove="TraceableSqlCommand.netframework.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' != 'netstandard2.0'">
<Compile Remove="TraceableSqlCommand.netstandard.cs" />
Expand Down
2 changes: 1 addition & 1 deletion sdk/src/Handlers/SqlServer/DbCommandInterceptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ protected virtual void CollectSqlInformation(DbCommand command)
private string BuildSubsegmentName(DbCommand command)
=> command.Connection.Database + "@" + SqlUtil.RemovePortNumberFromDataSource(command.Connection.DataSource);

#if !NET45
#if !NETFRAMEWORK
private bool ShouldCollectSqlText()
=> _collectSqlQueriesOverride ?? _recorder.XRayOptions.CollectSqlQueries;
#else
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//-----------------------------------------------------------------------------
// <copyright file="TraceableSqlCommand.net45.cs" company="Amazon.com">
// <copyright file="TraceableSqlCommand.netframework.cs" company="Amazon.com">
// Copyright 2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License").
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net45;netstandard2.0</TargetFrameworks>
<TargetFrameworks>net45;net462;netstandard2.0</TargetFrameworks>
<Company>Amazon.com, Inc</Company>
<Product>Amazon Web Service X-Ray Recorder</Product>
<Copyright>Copyright 2017-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.</Copyright>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


<PropertyGroup>
<TargetFrameworks>net45;netcoreapp2.0;netcoreapp3.1</TargetFrameworks>
<TargetFrameworks>net45;net462;netcoreapp2.0;netcoreapp3.1</TargetFrameworks>
<Company>Amazon.com, Inc</Company>
<Product>Amazon Web Service X-Ray Recorder</Product>
<Copyright>Copyright 2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.</Copyright>
Expand Down
31 changes: 2 additions & 29 deletions sdk/test/IntegrationTests/TestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Amazon.XRay;
using Amazon.XRay.Model;
using Amazon.XRay.Recorder.Core;
Expand Down Expand Up @@ -44,34 +45,7 @@ protected static void ClassCleanup()
Recorder.Dispose();
}

#if NET45
protected BatchGetTracesResponse BatchGetTraces(string traceId)
{
var request = new BatchGetTracesRequest();

request.TraceIds = new List<string>() { traceId };

int retries = 0;
BatchGetTracesResponse response = null;

while (retries < 60)
{
response = XrayClient.BatchGetTraces(request);
if (response.Traces.Count > 0)
{
break;
}
else
{
retries++;
Thread.Sleep(500);
}
}

return response;
}
#else
protected async System.Threading.Tasks.Task<BatchGetTracesResponse> BatchGetTracesAsync(string traceId)
protected async Task<BatchGetTracesResponse> BatchGetTracesAsync(string traceId)
{
var request = new BatchGetTracesRequest();
request.TraceIds = new List<string>() { traceId };
Expand All @@ -96,6 +70,5 @@ protected async System.Threading.Tasks.Task<BatchGetTracesResponse> BatchGetTrac

return response;
}
#endif
}
}
Loading

0 comments on commit ffcbf99

Please sign in to comment.