diff --git a/README.md b/README.md index cb79a9e60..0ae66a219 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ Powertools for AWS Lambda (.NET) provides three core utilities: ### Installation -The Powertools for AWS Lambda (.NET) utilities (.NET 6 and .NET 8) are available as NuGet packages. You can install the packages from [NuGet Gallery](https://www.nuget.org/packages?q=AWS+Lambda+Powertools*) or from Visual Studio editor by searching `AWS.Lambda.Powertools*` to see various utilities available. +The Powertools for AWS Lambda (.NET) utilities (.NET 8) are available as NuGet packages. You can install the packages from [NuGet Gallery](https://www.nuget.org/packages?q=AWS+Lambda+Powertools*) or from Visual Studio editor by searching `AWS.Lambda.Powertools*` to see various utilities available. * [AWS.Lambda.Powertools.Logging](https://www.nuget.org/packages?q=AWS.Lambda.Powertools.Logging): @@ -61,7 +61,7 @@ The Powertools for AWS Lambda (.NET) utilities (.NET 6 and .NET 8) are available ## Examples -We have provided examples focused specifically on each of the utilities. Each solution comes with an AWS Serverless Application Model (AWS SAM) templates to run your functions as a Zip package using the AWS Lambda .NET 6 or .NET 8 managed runtime; or as a container package using the AWS base images for .NET. +We have provided examples focused specifically on each of the utilities. Each solution comes with an AWS Serverless Application Model (AWS SAM) templates to run your functions as a Zip package using the AWS Lambda .NET 8 managed runtime; or as a container package using the AWS base images for .NET. * **[Logging example](examples/Logging/)** * **[Metrics example](examples/Metrics/)** diff --git a/docs/core/tracing.md b/docs/core/tracing.md index 6e16afde0..a9ad0632d 100644 --- a/docs/core/tracing.md +++ b/docs/core/tracing.md @@ -44,7 +44,7 @@ To enable active tracing on an AWS Serverless Application Model (AWS SAM) AWS::S Type: AWS::Serverless::Function Properties: ... - Runtime: dotnet6.0 + Runtime: dotnet8.0 Tracing: Active Environment: diff --git a/docs/index.md b/docs/index.md index 29875d66c..73b377cde 100644 --- a/docs/index.md +++ b/docs/index.md @@ -10,7 +10,7 @@ description: Powertools for AWS Lambda (.NET) Powertools for AWS Lambda (.NET) (which from here will be referred as Powertools) is a suite of utilities for [AWS Lambda](https://aws.amazon.com/lambda/) functions to ease adopting best practices such as tracing, structured logging, custom metrics, and more. !!! info - **Supports .NET 6 and .NET 8 runtimes** + **Supports .NET 8 runtime** ???+ tip Powertools is also available for [Python](https://docs.powertools.aws.dev/lambda/python/){target="_blank"}, [Java](https://docs.powertools.aws.dev/lambda/java/){target="_blank"}, and [TypeScript](https://docs.powertools.aws.dev/lambda/typescript/latest/){target="_blank"}. @@ -71,14 +71,14 @@ We have provided you with a custom template for the Serverless Application Model To use the SAM CLI, you need the following tools. * SAM CLI - [Install the SAM CLI](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html) -* .NET 6.0 (LTS) - [Install .NET 6.0](https://www.microsoft.com/net/download) +* .NET 8.0 (LTS) - [Install .NET 8.0](https://www.microsoft.com/net/download) * Docker - [Install Docker community edition](https://hub.docker.com/search/?type=edition&offering=community) -Once you have SAM CLI installed, follow the these steps to initialize a .NET 6 project using Powertools for AWS (.NET) +Once you have SAM CLI installed, follow the these steps to initialize a .NET 8 project using Powertools for AWS (.NET) 1. Run the following command in your command line ```bash - sam init -r dotnet6 + sam init -r dotnet8 ``` 2. Select option 1 as your template source diff --git a/docs/roadmap.md b/docs/roadmap.md index e88a50c15..2c2797947 100644 --- a/docs/roadmap.md +++ b/docs/roadmap.md @@ -46,7 +46,7 @@ Updating metrics implementation to support latest EMF specifications and improve Ensuring enterprise-grade security and compatibility with latest .NET developments. - [ ] .NET 10 support from day one -- [ ] Deprecation path for .NET 6 +- [x] .NET 6 deprecation completed - [ ] Scorecard implementation - [ ] Security compliance checks on our pipeline - [ ] All utilities with end-to-end tests in our pipeline diff --git a/examples/BatchProcessing/README.md b/examples/BatchProcessing/README.md index 33844d58a..2711c1f5e 100644 --- a/examples/BatchProcessing/README.md +++ b/examples/BatchProcessing/README.md @@ -28,7 +28,7 @@ To use the AWS SAM CLI, you need the following tools. * Docker - [Install Docker community edition](https://hub.docker.com/search/?type=edition&offering=community) You will need the following for local testing. -* .NET 6.0 - [Install .NET 6.0](https://www.microsoft.com/net/download) +* .NET 8.0 - [Install .NET 8.0](https://www.microsoft.com/net/download) To build and deploy your application for the first time, run the following in your shell. Make sure the `template.yaml` file is in your current directory: diff --git a/examples/Idempotency/README.md b/examples/Idempotency/README.md index bfe0e5daa..705350299 100644 --- a/examples/Idempotency/README.md +++ b/examples/Idempotency/README.md @@ -25,7 +25,7 @@ To use the AWS SAM CLI, you need the following tools. * Docker - [Install Docker community edition](https://hub.docker.com/search/?type=edition&offering=community) You will need the following for local testing. -* .NET 6.0 - [Install .NET 6.0](https://www.microsoft.com/net/download) +* .NET 8.0 - [Install .NET 8.0](https://www.microsoft.com/net/download) To build and deploy your application for the first time, run the following in your shell. Make sure the `template.yaml` file is in your current directory: diff --git a/examples/Logging/README.md b/examples/Logging/README.md index 2c39c60ab..85763dfe3 100644 --- a/examples/Logging/README.md +++ b/examples/Logging/README.md @@ -25,7 +25,7 @@ To use the AWS SAM CLI, you need the following tools. * Docker - [Install Docker community edition](https://hub.docker.com/search/?type=edition&offering=community) You will need the following for local testing. -* .NET 6.0 - [Install .NET 6.0](https://www.microsoft.com/net/download) +* .NET 8.0 - [Install .NET 8.0](https://www.microsoft.com/net/download) To build and deploy your application for the first time, run the following in your shell. Make sure the `template.yaml` file is in your current directory: diff --git a/examples/Metrics/README.md b/examples/Metrics/README.md index c3627883e..d3b483c3f 100644 --- a/examples/Metrics/README.md +++ b/examples/Metrics/README.md @@ -25,7 +25,7 @@ To use the AWS SAM CLI, you need the following tools. * Docker - [Install Docker community edition](https://hub.docker.com/search/?type=edition&offering=community) You will need the following for local testing. -* .NET 6.0 - [Install .NET 6.0](https://www.microsoft.com/net/download) +* .NET 8.0 - [Install .NET 8.0](https://www.microsoft.com/net/download) To build and deploy your application for the first time, run the following in your shell. Make sure the `template.yaml` file is in your current directory: diff --git a/examples/Parameters/README.md b/examples/Parameters/README.md index 633d69961..abd731057 100644 --- a/examples/Parameters/README.md +++ b/examples/Parameters/README.md @@ -25,7 +25,7 @@ To use the AWS SAM CLI, you need the following tools. * Docker - [Install Docker community edition](https://hub.docker.com/search/?type=edition&offering=community) You will need the following for local testing. -* .NET 6.0 - [Install .NET 6.0](https://www.microsoft.com/net/download) +* .NET 8.0 - [Install .NET 8.0](https://www.microsoft.com/net/download) To build and deploy your application for the first time, run the following in your shell. Make sure the `template.yaml` file is in your current directory: diff --git a/examples/ServerlessApi/Readme.md b/examples/ServerlessApi/Readme.md index 0da85b50d..e33d7aab5 100644 --- a/examples/ServerlessApi/Readme.md +++ b/examples/ServerlessApi/Readme.md @@ -27,7 +27,7 @@ To use the AWS SAM CLI, you need the following tools. * Docker - [Install Docker community edition](https://hub.docker.com/search/?type=edition&offering=community) You will need the following for local testing. -* .NET 6.0 - [Install .NET 6.0](https://www.microsoft.com/net/download) +* .NET 8.0 - [Install .NET 8.0](https://www.microsoft.com/net/download) To build and deploy your application for the first time, run the following in your shell. Make sure the `serverless.template` file is in your current directory: diff --git a/examples/Tracing/README.md b/examples/Tracing/README.md index 44586ae44..04c3ffdef 100644 --- a/examples/Tracing/README.md +++ b/examples/Tracing/README.md @@ -25,7 +25,7 @@ To use the AWS SAM CLI, you need the following tools. * Docker - [Install Docker community edition](https://hub.docker.com/search/?type=edition&offering=community) You will need the following for local testing. -* .NET 6.0 - [Install .NET 6.0](https://www.microsoft.com/net/download) +* .NET 8.0 - [Install .NET 8.0](https://www.microsoft.com/net/download) To build and deploy your application for the first time, run the following in your shell. Make sure the `template.yaml` file is in your current directory: diff --git a/libraries/src/AWS.Lambda.Powertools.Idempotency/Idempotency.cs b/libraries/src/AWS.Lambda.Powertools.Idempotency/Idempotency.cs index 0685cb165..2e626fb34 100644 --- a/libraries/src/AWS.Lambda.Powertools.Idempotency/Idempotency.cs +++ b/libraries/src/AWS.Lambda.Powertools.Idempotency/Idempotency.cs @@ -181,7 +181,6 @@ public IdempotencyBuilder WithOptions(IdempotencyOptions options) return this; } -#if NET8_0_OR_GREATER /// /// Set Customer JsonSerializerContext to append to IdempotencySerializationContext /// @@ -192,6 +191,5 @@ public IdempotencyBuilder WithJsonSerializationContext(JsonSerializerContext con IdempotencySerializer.AddTypeInfoResolver(context); return this; } -#endif } } \ No newline at end of file diff --git a/libraries/src/AWS.Lambda.Powertools.Idempotency/IdempotencyOptionsBuilder.cs b/libraries/src/AWS.Lambda.Powertools.Idempotency/IdempotencyOptionsBuilder.cs index 1371f8e7c..3c437d337 100644 --- a/libraries/src/AWS.Lambda.Powertools.Idempotency/IdempotencyOptionsBuilder.cs +++ b/libraries/src/AWS.Lambda.Powertools.Idempotency/IdempotencyOptionsBuilder.cs @@ -122,15 +122,9 @@ public IdempotencyOptionsBuilder WithExpiration(TimeSpan duration) /// /// Can be any algorithm supported by HashAlgorithm.Create /// the instance of the builder (to chain operations) -#if NET8_0_OR_GREATER [Obsolete("Idempotency uses MD5 and does not support other hash algorithms.")] -#endif public IdempotencyOptionsBuilder WithHashFunction(string hashFunction) { -#if NET6_0 - // for backward compability keep this code in .net 6 - _hashFunction = hashFunction; -#endif return this; } } \ No newline at end of file diff --git a/libraries/src/AWS.Lambda.Powertools.Idempotency/Internal/Serializers/IdempotencySerializationContext.cs b/libraries/src/AWS.Lambda.Powertools.Idempotency/Internal/Serializers/IdempotencySerializationContext.cs index 6f77b9cfb..4b96bb649 100644 --- a/libraries/src/AWS.Lambda.Powertools.Idempotency/Internal/Serializers/IdempotencySerializationContext.cs +++ b/libraries/src/AWS.Lambda.Powertools.Idempotency/Internal/Serializers/IdempotencySerializationContext.cs @@ -17,8 +17,6 @@ namespace AWS.Lambda.Powertools.Idempotency.Internal.Serializers; -#if NET8_0_OR_GREATER - /// /// The source generated JsonSerializerContext to be used to Serialize Idempotency types @@ -28,5 +26,4 @@ namespace AWS.Lambda.Powertools.Idempotency.Internal.Serializers; public partial class IdempotencySerializationContext : JsonSerializerContext { -} -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/libraries/src/AWS.Lambda.Powertools.Idempotency/Internal/Serializers/IdempotencySerializer.cs b/libraries/src/AWS.Lambda.Powertools.Idempotency/Internal/Serializers/IdempotencySerializer.cs index 823603ee7..b7f984193 100644 --- a/libraries/src/AWS.Lambda.Powertools.Idempotency/Internal/Serializers/IdempotencySerializer.cs +++ b/libraries/src/AWS.Lambda.Powertools.Idempotency/Internal/Serializers/IdempotencySerializer.cs @@ -44,22 +44,18 @@ private static void BuildDefaultOptions() { PropertyNameCaseInsensitive = true }; -#if NET8_0_OR_GREATER if (!RuntimeFeatureWrapper.IsDynamicCodeSupported) { _jsonOptions.TypeInfoResolverChain.Add(IdempotencySerializationContext.Default); } -#endif } -#if NET8_0_OR_GREATER - /// /// Adds a JsonTypeInfoResolver to the JsonSerializerOptions. /// /// The JsonTypeInfoResolver to add. /// - /// This method is only available in .NET 8.0 and later versions. + /// This method is available in .NET 8.0 and later versions. /// internal static void AddTypeInfoResolver(JsonSerializerContext context) { @@ -88,7 +84,6 @@ internal static void SetJsonOptions(JsonSerializerOptions options) { _jsonOptions = options; } -#endif /// /// Serializes the specified object to a JSON string. @@ -98,9 +93,6 @@ internal static void SetJsonOptions(JsonSerializerOptions options) /// A JSON string representation of the object. internal static string Serialize(object value, Type inputType) { -#if NET6_0 - return JsonSerializer.Serialize(value, _jsonOptions); -#else if (RuntimeFeatureWrapper.IsDynamicCodeSupported) { #pragma warning disable @@ -115,7 +107,6 @@ internal static string Serialize(object value, Type inputType) } return JsonSerializer.Serialize(value, typeInfo); -#endif } /// @@ -128,15 +119,11 @@ internal static string Serialize(object value, Type inputType) [UnconditionalSuppressMessage("AOT", "IL3050:Calling members annotated with 'RequiresDynamicCodeAttribute' may break functionality when AOT compiling.", Justification = "False positive")] internal static T Deserialize(string value) { -#if NET6_0 - return JsonSerializer.Deserialize(value,_jsonOptions); -#else if (RuntimeFeatureWrapper.IsDynamicCodeSupported) { return JsonSerializer.Deserialize(value, _jsonOptions); } return (T)JsonSerializer.Deserialize(value, GetTypeInfo(typeof(T))); -#endif } } \ No newline at end of file diff --git a/libraries/src/AWS.Lambda.Powertools.Idempotency/Persistence/BasePersistenceStore.cs b/libraries/src/AWS.Lambda.Powertools.Idempotency/Persistence/BasePersistenceStore.cs index 3cf9b1f62..e2006b0cb 100644 --- a/libraries/src/AWS.Lambda.Powertools.Idempotency/Persistence/BasePersistenceStore.cs +++ b/libraries/src/AWS.Lambda.Powertools.Idempotency/Persistence/BasePersistenceStore.cs @@ -339,12 +339,8 @@ private static bool IsMissingIdempotencyKey(JsonElement data) /// internal string GenerateHash(JsonElement data) { -#if NET8_0_OR_GREATER // starting .NET 8 no option to change hash algorithm using var hashAlgorithm = MD5.Create(); -#else - using var hashAlgorithm = HashAlgorithm.Create(_idempotencyOptions.HashFunction); -#endif if (hashAlgorithm == null) { throw new ArgumentException("Invalid HashAlgorithm"); diff --git a/libraries/src/AWS.Lambda.Powertools.JMESPath/Serializers/JMESPathSerializationContext.cs b/libraries/src/AWS.Lambda.Powertools.JMESPath/Serializers/JMESPathSerializationContext.cs index 96611cdec..cb158f88a 100644 --- a/libraries/src/AWS.Lambda.Powertools.JMESPath/Serializers/JMESPathSerializationContext.cs +++ b/libraries/src/AWS.Lambda.Powertools.JMESPath/Serializers/JMESPathSerializationContext.cs @@ -18,8 +18,6 @@ namespace AWS.Lambda.Powertools.JMESPath.Serializers; -#if NET8_0_OR_GREATER - /// /// The source generated JsonSerializerContext to be used to Serialize JMESPath types /// @@ -32,5 +30,3 @@ namespace AWS.Lambda.Powertools.JMESPath.Serializers; public partial class JmesPathSerializationContext : JsonSerializerContext { } - -#endif \ No newline at end of file diff --git a/libraries/src/AWS.Lambda.Powertools.JMESPath/Serializers/JMESPathSerializer.cs b/libraries/src/AWS.Lambda.Powertools.JMESPath/Serializers/JMESPathSerializer.cs index b599145f7..3886a54ca 100644 --- a/libraries/src/AWS.Lambda.Powertools.JMESPath/Serializers/JMESPathSerializer.cs +++ b/libraries/src/AWS.Lambda.Powertools.JMESPath/Serializers/JMESPathSerializer.cs @@ -31,12 +31,7 @@ internal static class JmesPathSerializer /// System.String. internal static string Serialize(object value, Type inputType) { -#if NET6_0 - return JsonSerializer.Serialize(value); -#else - return JsonSerializer.Serialize(value, inputType, JmesPathSerializationContext.Default); -#endif } /// @@ -47,11 +42,6 @@ internal static string Serialize(object value, Type inputType) /// T. internal static T Deserialize(string value) { -#if NET6_0 - return JsonSerializer.Deserialize(value); -#else - return (T)JsonSerializer.Deserialize(value, typeof(T), JmesPathSerializationContext.Default); -#endif } } \ No newline at end of file diff --git a/libraries/src/AWS.Lambda.Powertools.Logging/Internal/PowertoolsLogger.cs b/libraries/src/AWS.Lambda.Powertools.Logging/Internal/PowertoolsLogger.cs index 6e72d102d..5e603c02d 100644 --- a/libraries/src/AWS.Lambda.Powertools.Logging/Internal/PowertoolsLogger.cs +++ b/libraries/src/AWS.Lambda.Powertools.Logging/Internal/PowertoolsLogger.cs @@ -261,11 +261,7 @@ private object GetFormattedLogEntry(LogLevel logLevel, DateTime timestamp, objec var logObject = logFormatter.FormatLogEntry(logEntry); if (logObject is null) throw new LogFormatException($"{logFormatter.GetType().FullName} returned Null value."); -#if NET8_0_OR_GREATER return PowertoolsLoggerHelpers.ObjectToDictionary(logObject); -#else - return logObject; -#endif } catch (Exception e) { @@ -289,13 +285,8 @@ private static bool CustomFormatter(TState state, Exception exception, o if (exception is not null) return false; -#if NET8_0_OR_GREATER var stateKeys = (state as IEnumerable>)? .ToDictionary(i => i.Key, i => PowertoolsLoggerHelpers.ObjectToDictionary(i.Value)); -#else - var stateKeys = (state as IEnumerable>)? - .ToDictionary(i => i.Key, i => i.Value); -#endif if (stateKeys is null || stateKeys.Count != 2) return false; diff --git a/libraries/src/AWS.Lambda.Powertools.Logging/Logger.cs b/libraries/src/AWS.Lambda.Powertools.Logging/Logger.cs index 4271de832..f07464ed6 100644 --- a/libraries/src/AWS.Lambda.Powertools.Logging/Logger.cs +++ b/libraries/src/AWS.Lambda.Powertools.Logging/Logger.cs @@ -96,12 +96,8 @@ public static void AppendKey(string key, object value) if (string.IsNullOrWhiteSpace(key)) throw new ArgumentNullException(nameof(key)); -#if NET8_0_OR_GREATER Scope[key] = PowertoolsLoggerHelpers.ObjectToDictionary(value) ?? throw new ArgumentNullException(nameof(value)); -#else - Scope[key] = value ?? throw new ArgumentNullException(nameof(value)); -#endif } /// diff --git a/libraries/src/AWS.Lambda.Powertools.Logging/Serializers/LoggingSerializationContext.cs b/libraries/src/AWS.Lambda.Powertools.Logging/Serializers/LoggingSerializationContext.cs index 28692b8ef..459a3b0fa 100644 --- a/libraries/src/AWS.Lambda.Powertools.Logging/Serializers/LoggingSerializationContext.cs +++ b/libraries/src/AWS.Lambda.Powertools.Logging/Serializers/LoggingSerializationContext.cs @@ -20,8 +20,6 @@ namespace AWS.Lambda.Powertools.Logging.Serializers; -#if NET8_0_OR_GREATER - /// /// Custom JSON serializer context for AWS.Lambda.Powertools.Logging /// @@ -44,5 +42,3 @@ public partial class PowertoolsLoggingSerializationContext : JsonSerializerConte { } - -#endif \ No newline at end of file diff --git a/libraries/src/AWS.Lambda.Powertools.Logging/Serializers/PowertoolsLoggingSerializer.cs b/libraries/src/AWS.Lambda.Powertools.Logging/Serializers/PowertoolsLoggingSerializer.cs index 97aabc06c..b13fb6c18 100644 --- a/libraries/src/AWS.Lambda.Powertools.Logging/Serializers/PowertoolsLoggingSerializer.cs +++ b/libraries/src/AWS.Lambda.Powertools.Logging/Serializers/PowertoolsLoggingSerializer.cs @@ -66,10 +66,6 @@ internal static void ConfigureNamingPolicy(LoggerOutputCase loggerOutputCase) /// Thrown when the input type is not known to the serializer. internal static string Serialize(object value, Type inputType) { -#if NET6_0 - var options = GetSerializerOptions(); - return JsonSerializer.Serialize(value, options); -#else if (RuntimeFeatureWrapper.IsDynamicCodeSupported) { var options = GetSerializerOptions(); @@ -85,10 +81,8 @@ internal static string Serialize(object value, Type inputType) } return JsonSerializer.Serialize(value, typeInfo); -#endif } -#if NET8_0_OR_GREATER /// /// Adds a JsonSerializerContext to the serializer options. /// @@ -114,7 +108,6 @@ internal static JsonTypeInfo GetTypeInfo(Type type) var options = GetSerializerOptions(); return options.TypeInfoResolver?.GetTypeInfo(type, options); } -#endif /// /// Builds and configures the JsonSerializerOptions. @@ -135,13 +128,8 @@ private static JsonSerializerOptions BuildJsonSerializerOptions() _jsonOptions.DictionaryKeyPolicy = PascalCaseNamingPolicy.Instance; break; default: // Snake case -#if NET8_0_OR_GREATER _jsonOptions.PropertyNamingPolicy = JsonNamingPolicy.SnakeCaseLower; _jsonOptions.DictionaryKeyPolicy = JsonNamingPolicy.SnakeCaseLower; -#else - _jsonOptions.PropertyNamingPolicy = SnakeCaseNamingPolicy.Instance; - _jsonOptions.DictionaryKeyPolicy = SnakeCaseNamingPolicy.Instance; -#endif break; } @@ -152,17 +140,11 @@ private static JsonSerializerOptions BuildJsonSerializerOptions() _jsonOptions.Converters.Add(new DateOnlyConverter()); _jsonOptions.Converters.Add(new TimeOnlyConverter()); -#if NET8_0_OR_GREATER - _jsonOptions.Converters.Add(new LogLevelJsonConverter()); -#elif NET6_0 _jsonOptions.Converters.Add(new LogLevelJsonConverter()); -#endif _jsonOptions.Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping; _jsonOptions.PropertyNameCaseInsensitive = true; -#if NET8_0_OR_GREATER - // Only add TypeInfoResolver if AOT mode if (!RuntimeFeatureWrapper.IsDynamicCodeSupported) { @@ -172,11 +154,9 @@ private static JsonSerializerOptions BuildJsonSerializerOptions() _jsonOptions.TypeInfoResolverChain.Add(context); } } -#endif return _jsonOptions; } -#if NET8_0_OR_GREATER internal static bool HasContext(JsonSerializerContext customContext) { return AdditionalContexts.Contains(customContext); @@ -186,7 +166,6 @@ internal static void ClearContext() { AdditionalContexts.Clear(); } -#endif /// /// Clears options for tests diff --git a/libraries/src/AWS.Lambda.Powertools.Logging/Serializers/PowertoolsSourceGeneratorSerializer.cs b/libraries/src/AWS.Lambda.Powertools.Logging/Serializers/PowertoolsSourceGeneratorSerializer.cs index dadec8dad..8871fb950 100644 --- a/libraries/src/AWS.Lambda.Powertools.Logging/Serializers/PowertoolsSourceGeneratorSerializer.cs +++ b/libraries/src/AWS.Lambda.Powertools.Logging/Serializers/PowertoolsSourceGeneratorSerializer.cs @@ -13,8 +13,6 @@ * permissions and limitations under the License. */ -#if NET8_0_OR_GREATER - using System; using System.Diagnostics.CodeAnalysis; using System.Text.Json; @@ -77,5 +75,3 @@ public PowertoolsSourceGeneratorSerializer( PowertoolsLoggingSerializer.AddSerializerContext(jsonSerializerContext); } } - -#endif \ No newline at end of file diff --git a/libraries/src/AWS.Lambda.Powertools.Metrics/Model/MetricUnit.cs b/libraries/src/AWS.Lambda.Powertools.Metrics/Model/MetricUnit.cs index 2fbb389d9..ddf091c5e 100644 --- a/libraries/src/AWS.Lambda.Powertools.Metrics/Model/MetricUnit.cs +++ b/libraries/src/AWS.Lambda.Powertools.Metrics/Model/MetricUnit.cs @@ -21,11 +21,7 @@ namespace AWS.Lambda.Powertools.Metrics; /// /// Enum MetricUnit /// -#if NET8_0_OR_GREATER [JsonConverter(typeof(JsonStringEnumConverter))] -#else -[JsonConverter(typeof(JsonStringEnumConverter))] -#endif public enum MetricUnit { /// diff --git a/libraries/src/AWS.Lambda.Powertools.Metrics/Model/RootNode.cs b/libraries/src/AWS.Lambda.Powertools.Metrics/Model/RootNode.cs index 496606cd1..91ccdc9f8 100644 --- a/libraries/src/AWS.Lambda.Powertools.Metrics/Model/RootNode.cs +++ b/libraries/src/AWS.Lambda.Powertools.Metrics/Model/RootNode.cs @@ -65,11 +65,6 @@ public string Serialize() { if (string.IsNullOrWhiteSpace(AWS.GetNamespace())) throw new SchemaValidationException("namespace"); -#if NET8_0_OR_GREATER - return JsonSerializer.Serialize(this, typeof(RootNode), MetricsSerializationContext.Default); -#else - return JsonSerializer.Serialize(this); -#endif } } \ No newline at end of file diff --git a/libraries/src/AWS.Lambda.Powertools.Metrics/Serializer/MetricsSerializationContext.cs b/libraries/src/AWS.Lambda.Powertools.Metrics/Serializer/MetricsSerializationContext.cs index e8a421ac8..05317c4a7 100644 --- a/libraries/src/AWS.Lambda.Powertools.Metrics/Serializer/MetricsSerializationContext.cs +++ b/libraries/src/AWS.Lambda.Powertools.Metrics/Serializer/MetricsSerializationContext.cs @@ -18,7 +18,6 @@ namespace AWS.Lambda.Powertools.Metrics; -#if NET8_0_OR_GREATER /// /// Source generator for Metrics types /// @@ -36,5 +35,4 @@ namespace AWS.Lambda.Powertools.Metrics; public partial class MetricsSerializationContext : JsonSerializerContext { -} -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/libraries/src/AWS.Lambda.Powertools.Tracing/Internal/TracingAspect.cs b/libraries/src/AWS.Lambda.Powertools.Tracing/Internal/TracingAspect.cs index 2e860ddd3..6052bb682 100644 --- a/libraries/src/AWS.Lambda.Powertools.Tracing/Internal/TracingAspect.cs +++ b/libraries/src/AWS.Lambda.Powertools.Tracing/Internal/TracingAspect.cs @@ -168,7 +168,6 @@ private void HandleResponse(string name, object result, TracingCaptureMode captu // Skip if the result is VoidTaskResult if (result.GetType().Name == "VoidTaskResult") return; -#if NET8_0_OR_GREATER if (!RuntimeFeatureWrapper.IsDynamicCodeSupported) // is AOT { _xRayRecorder.AddMetadata( @@ -178,7 +177,6 @@ private void HandleResponse(string name, object result, TracingCaptureMode captu ); return; } -#endif _xRayRecorder.AddMetadata( @namespace, diff --git a/libraries/src/AWS.Lambda.Powertools.Tracing/Serializers/PowertoolsTracingSerializer.cs b/libraries/src/AWS.Lambda.Powertools.Tracing/Serializers/PowertoolsTracingSerializer.cs index 52e774109..fca467259 100644 --- a/libraries/src/AWS.Lambda.Powertools.Tracing/Serializers/PowertoolsTracingSerializer.cs +++ b/libraries/src/AWS.Lambda.Powertools.Tracing/Serializers/PowertoolsTracingSerializer.cs @@ -14,8 +14,6 @@ */ -#if NET8_0_OR_GREATER - using System; using System.Collections.Generic; using System.Text.Json; @@ -104,5 +102,3 @@ private static object ConvertValue(JsonElement element) } } } - -#endif \ No newline at end of file diff --git a/libraries/src/AWS.Lambda.Powertools.Tracing/Serializers/TracingSerializerExtensions.cs b/libraries/src/AWS.Lambda.Powertools.Tracing/Serializers/TracingSerializerExtensions.cs index 5aee45b22..9287c6977 100644 --- a/libraries/src/AWS.Lambda.Powertools.Tracing/Serializers/TracingSerializerExtensions.cs +++ b/libraries/src/AWS.Lambda.Powertools.Tracing/Serializers/TracingSerializerExtensions.cs @@ -13,8 +13,6 @@ * permissions and limitations under the License. */ -#if NET8_0_OR_GREATER - using System; using System.Diagnostics.CodeAnalysis; using System.Text.Json; @@ -55,5 +53,3 @@ internal static JsonSerializerOptions GetDefaultOptions() return serializer; } } - -#endif \ No newline at end of file diff --git a/libraries/src/Directory.Build.props b/libraries/src/Directory.Build.props index ab02fae1a..7d7d53060 100644 --- a/libraries/src/Directory.Build.props +++ b/libraries/src/Directory.Build.props @@ -1,6 +1,6 @@ - net6.0;net8.0 + net8.0 default 0.0.1 diff --git a/libraries/tests/AWS.Lambda.Powertools.Idempotency.Tests/Internal/IdempotencySerializerTests.cs b/libraries/tests/AWS.Lambda.Powertools.Idempotency.Tests/Internal/IdempotencySerializerTests.cs index 065c985cb..819b01308 100644 --- a/libraries/tests/AWS.Lambda.Powertools.Idempotency.Tests/Internal/IdempotencySerializerTests.cs +++ b/libraries/tests/AWS.Lambda.Powertools.Idempotency.Tests/Internal/IdempotencySerializerTests.cs @@ -14,9 +14,7 @@ public class IdempotencySerializerTests { public IdempotencySerializerTests() { -#if NET8_0_OR_GREATER IdempotencySerializer.AddTypeInfoResolver(TestJsonSerializerContext.Default); -#endif } [Fact] @@ -59,8 +57,6 @@ public void BuildDefaultOptions_SetsCorrectProperties() Assert.True(options.PropertyNameCaseInsensitive); } -#if NET8_0_OR_GREATER - [Fact] public void GetTypeInfo_UnknownType_ThrowsException() { @@ -155,5 +151,4 @@ public void SetJsonOptions_UpdatesOptionsCorrectly() Assert.Same(newOptions, options); } -#endif } \ No newline at end of file diff --git a/libraries/tests/AWS.Lambda.Powertools.Idempotency.Tests/Internal/IdempotentAspectTests.cs b/libraries/tests/AWS.Lambda.Powertools.Idempotency.Tests/Internal/IdempotentAspectTests.cs index f83cfe343..f91ee7b83 100644 --- a/libraries/tests/AWS.Lambda.Powertools.Idempotency.Tests/Internal/IdempotentAspectTests.cs +++ b/libraries/tests/AWS.Lambda.Powertools.Idempotency.Tests/Internal/IdempotentAspectTests.cs @@ -41,9 +41,7 @@ public async Task Handle_WhenFirstCall_ShouldPutInStore(Type type) var store = Substitute.For(); Idempotency.Configure(builder => builder -#if NET8_0_OR_GREATER .WithJsonSerializationContext(TestJsonSerializerContext.Default) -#endif .WithPersistenceStore(store) .WithOptions(optionsBuilder => optionsBuilder.WithEventKeyJmesPath("Id")) ); @@ -89,9 +87,7 @@ public async Task Handle_WhenSecondCall_AndNotExpired_ShouldGetFromStore(Type ty // GIVEN Idempotency.Configure(builder => builder -#if NET8_0_OR_GREATER .WithJsonSerializationContext(TestJsonSerializerContext.Default) -#endif .WithPersistenceStore(store) .WithOptions(optionsBuilder => optionsBuilder.WithEventKeyJmesPath("Id")) ); @@ -128,9 +124,7 @@ public async Task Handle_WhenSecondCall_AndStatusInProgress_ShouldThrowIdempoten Idempotency.Configure(builder => builder .WithPersistenceStore(store) -#if NET8_0_OR_GREATER .WithJsonSerializationContext(TestJsonSerializerContext.Default) -#endif .WithOptions(optionsBuilder => optionsBuilder.WithEventKeyJmesPath("Id")) ); @@ -169,9 +163,7 @@ public async Task Idempotency.Configure(builder => builder .WithPersistenceStore(store) -#if NET8_0_OR_GREATER .WithJsonSerializationContext(TestJsonSerializerContext.Default) -#endif .WithOptions(optionsBuilder => optionsBuilder.WithEventKeyJmesPath("Id")) ); @@ -212,9 +204,7 @@ public async Task Handle_WhenThrowException_ShouldDeleteRecord_AndThrowFunctionE Idempotency.Configure(builder => builder .WithPersistenceStore(store) -#if NET8_0_OR_GREATER .WithJsonSerializationContext(TestJsonSerializerContext.Default) -#endif .WithOptions(optionsBuilder => optionsBuilder.WithEventKeyJmesPath("Id")) ); @@ -242,9 +232,7 @@ public async Task Handle_WhenIdempotencyDisabled_ShouldJustRunTheFunction(Type t Idempotency.Configure(builder => builder .WithPersistenceStore(store) -#if NET8_0_OR_GREATER .WithJsonSerializationContext(TestJsonSerializerContext.Default) -#endif .WithOptions(optionsBuilder => optionsBuilder.WithEventKeyJmesPath("Id")) ); @@ -360,9 +348,7 @@ public async Task Handle_WhenIdempotencyOnSubMethodAnnotated_AndKeyJMESPath_Shou Idempotency.Configure(builder => builder .WithPersistenceStore(store) -#if NET8_0_OR_GREATER .WithJsonSerializationContext(TestJsonSerializerContext.Default) -#endif .WithOptions(optionsBuilder => optionsBuilder.WithEventKeyJmesPath("Id")) ); diff --git a/libraries/tests/AWS.Lambda.Powertools.Idempotency.Tests/Persistence/BasePersistenceStoreTests.cs b/libraries/tests/AWS.Lambda.Powertools.Idempotency.Tests/Persistence/BasePersistenceStoreTests.cs index 0aed14405..ad93313b6 100644 --- a/libraries/tests/AWS.Lambda.Powertools.Idempotency.Tests/Persistence/BasePersistenceStoreTests.cs +++ b/libraries/tests/AWS.Lambda.Powertools.Idempotency.Tests/Persistence/BasePersistenceStoreTests.cs @@ -566,9 +566,7 @@ private static APIGatewayProxyRequest LoadApiGatewayProxyRequest() var eventJson = File.ReadAllText("./resources/apigw_event.json"); try { -#if NET8_0_OR_GREATER IdempotencySerializer.AddTypeInfoResolver(TestJsonSerializerContext.Default); -#endif var request = IdempotencySerializer.Deserialize(eventJson); return request!; } diff --git a/libraries/tests/AWS.Lambda.Powertools.Logging.Tests/Attributes/LoggerAspectTests.cs b/libraries/tests/AWS.Lambda.Powertools.Logging.Tests/Attributes/LoggerAspectTests.cs index ba08453f1..f3a8335e6 100644 --- a/libraries/tests/AWS.Lambda.Powertools.Logging.Tests/Attributes/LoggerAspectTests.cs +++ b/libraries/tests/AWS.Lambda.Powertools.Logging.Tests/Attributes/LoggerAspectTests.cs @@ -41,10 +41,8 @@ public LoggerAspectTests() public void OnEntry_ShouldInitializeLogger_WhenCalledWithValidArguments() { // Arrange -#if NET8_0_OR_GREATER // Add seriolization context for AOT PowertoolsLoggingSerializer.AddSerializerContext(TestJsonContext.Default); -#endif var instance = new object(); var name = "TestMethod"; @@ -84,11 +82,8 @@ public void OnEntry_ShouldInitializeLogger_WhenCalledWithValidArguments() public void OnEntry_ShouldLog_Event_When_EnvironmentVariable_Set() { // Arrange -#if NET8_0_OR_GREATER - // Add seriolization context for AOT PowertoolsLoggingSerializer.AddSerializerContext(TestJsonContext.Default); -#endif var instance = new object(); var name = "TestMethod"; @@ -134,11 +129,8 @@ public void OnEntry_ShouldLog_Event_When_EnvironmentVariable_Set() public void OnEntry_ShouldLog_SamplingRate_When_EnvironmentVariable_Set() { // Arrange -#if NET8_0_OR_GREATER - // Add seriolization context for AOT PowertoolsLoggingSerializer.AddSerializerContext(TestJsonContext.Default); -#endif var instance = new object(); var name = "TestMethod"; @@ -209,11 +201,8 @@ public void OnEntry_ShouldLogEvent_WhenLogEventIsTrue() public void OnEntry_ShouldNot_Log_Info_When_LogLevel_Higher_EnvironmentVariable() { // Arrange -#if NET8_0_OR_GREATER - // Add seriolization context for AOT PowertoolsLoggingSerializer.AddSerializerContext(TestJsonContext.Default); -#endif var instance = new object(); var name = "TestMethod"; @@ -253,11 +242,8 @@ public void OnEntry_ShouldNot_Log_Info_When_LogLevel_Higher_EnvironmentVariable( public void OnEntry_Should_LogDebug_WhenSet_EnvironmentVariable() { // Arrange -#if NET8_0_OR_GREATER - // Add seriolization context for AOT PowertoolsLoggingSerializer.AddSerializerContext(TestJsonContext.Default); -#endif var instance = new object(); var name = "TestMethod"; diff --git a/libraries/tests/AWS.Lambda.Powertools.Logging.Tests/Attributes/LoggingAttributeTest.cs b/libraries/tests/AWS.Lambda.Powertools.Logging.Tests/Attributes/LoggingAttributeTest.cs index 892a2bafe..9843c71ef 100644 --- a/libraries/tests/AWS.Lambda.Powertools.Logging.Tests/Attributes/LoggingAttributeTest.cs +++ b/libraries/tests/AWS.Lambda.Powertools.Logging.Tests/Attributes/LoggingAttributeTest.cs @@ -119,11 +119,8 @@ public void OnEntry_WhenEventArgExist_LogEvent() SystemWrapper.Instance.SetOut(consoleOut); var correlationId = Guid.NewGuid().ToString(); -#if NET8_0_OR_GREATER - // Add seriolization context for AOT PowertoolsLoggingSerializer.AddSerializerContext(TestJsonContext.Default); -#endif var context = new TestLambdaContext() { FunctionName = "PowertoolsLoggingSample-HelloWorldFunction-Gg8rhPwO7Wa1" @@ -152,11 +149,8 @@ public void OnEntry_WhenEventArgExist_LogEvent_False_Should_Not_Log() var consoleOut = Substitute.For(); SystemWrapper.Instance.SetOut(consoleOut); -#if NET8_0_OR_GREATER - // Add seriolization context for AOT PowertoolsLoggingSerializer.AddSerializerContext(TestJsonContext.Default); -#endif var context = new TestLambdaContext() { FunctionName = "PowertoolsLoggingSample-HelloWorldFunction-Gg8rhPwO7Wa1" @@ -209,11 +203,8 @@ public void OnEntry_WhenEventArgExists_CapturesCorrelationId(string correlationI // Arrange var correlationId = Guid.NewGuid().ToString(); -#if NET8_0_OR_GREATER - // Add seriolization context for AOT PowertoolsLoggingSerializer.AddSerializerContext(TestJsonContext.Default); -#endif // Act switch (correlationIdPath) @@ -270,11 +261,8 @@ public void When_Capturing_CorrelationId_Converts_To_Case(LoggerOutputCase outpu // Arrange var correlationId = Guid.NewGuid().ToString(); -#if NET8_0_OR_GREATER - // Add seriolization context for AOT PowertoolsLoggingSerializer.AddSerializerContext(TestJsonContext.Default); -#endif // Act switch (outputCase) @@ -325,11 +313,8 @@ public void When_Capturing_CorrelationId_Converts_To_Case_From_Environment_Var(L // Arrange var correlationId = Guid.NewGuid().ToString(); -#if NET8_0_OR_GREATER - // Add seriolization context for AOT PowertoolsLoggingSerializer.AddSerializerContext(TestJsonContext.Default); -#endif // Act switch (outputCase) diff --git a/libraries/tests/AWS.Lambda.Powertools.Logging.Tests/Formatter/LogFormatterTest.cs b/libraries/tests/AWS.Lambda.Powertools.Logging.Tests/Formatter/LogFormatterTest.cs index b9bc8708e..a1f055f9b 100644 --- a/libraries/tests/AWS.Lambda.Powertools.Logging.Tests/Formatter/LogFormatterTest.cs +++ b/libraries/tests/AWS.Lambda.Powertools.Logging.Tests/Formatter/LogFormatterTest.cs @@ -244,19 +244,11 @@ public void Should_Log_CustomFormatter_When_Decorated() // serializer works differently in .net 8 and AOT. In .net 6 it writes properties that have null // in .net 8 it removes null properties -#if NET8_0_OR_GREATER consoleOut.Received(1).WriteLine( Arg.Is(i => i.Contains( "\"correlation_ids\":{\"aws_request_id\":\"requestId\"},\"lambda_function\":{\"name\":\"funtionName\",\"arn\":\"function::arn\",\"memory_limit_in_mb\":128,\"version\":\"version\",\"cold_start\":true},\"level\":\"Information\"")) ); -#else - consoleOut.Received(1).WriteLine( - Arg.Is(i => - i.Contains( - "{\"message\":\"test\",\"service\":\"my_service\",\"correlation_ids\":{\"aws_request_id\":\"requestId\",\"x_ray_trace_id\":null,\"correlation_id\":null},\"lambda_function\":{\"name\":\"funtionName\",\"arn\":\"function::arn\",\"memory_limit_in_m_b\":128,\"version\":\"version\",\"cold_start\":true},\"level\":\"Information\",\"timestamp\":\"2024-01-01T00:00:00.0000000\",\"logger\":{\"name\":\"AWS.Lambda.Powertools.Logging.Logger\",\"sample_rate\"")) - ); -#endif } [Fact] @@ -280,19 +272,11 @@ public void Should_Log_CustomFormatter_When_No_Decorated_Just_Log() // serializer works differently in .net 8 and AOT. In .net 6 it writes properties that have null // in .net 8 it removes null properties -#if NET8_0_OR_GREATER consoleOut.Received(1).WriteLine( Arg.Is(i => i == "{\"message\":\"test\",\"service\":\"service_undefined\",\"correlation_ids\":{},\"lambda_function\":{\"cold_start\":true},\"level\":\"Information\",\"timestamp\":\"2024-01-01T00:00:00.0000000\",\"logger\":{\"name\":\"AWS.Lambda.Powertools.Logging.Logger\",\"sample_rate\":0}}") ); -#else - consoleOut.Received(1).WriteLine( - Arg.Is(i => - i == - "{\"message\":\"test\",\"service\":\"service_undefined\",\"correlation_ids\":{\"aws_request_id\":null,\"x_ray_trace_id\":null,\"correlation_id\":null},\"lambda_function\":{\"name\":null,\"arn\":null,\"memory_limit_in_m_b\":null,\"version\":null,\"cold_start\":true},\"level\":\"Information\",\"timestamp\":\"2024-01-01T00:00:00.0000000\",\"logger\":{\"name\":\"AWS.Lambda.Powertools.Logging.Logger\",\"sample_rate\":0}}") - ); -#endif } [Fact] @@ -305,19 +289,11 @@ public void Should_Log_CustomFormatter_When_Decorated_No_Context() _testHandler.TestCustomFormatterWithDecoratorNoContext("test"); -#if NET8_0_OR_GREATER consoleOut.Received(1).WriteLine( Arg.Is(i => i == "{\"message\":\"test\",\"service\":\"my_service\",\"correlation_ids\":{},\"lambda_function\":{\"cold_start\":true},\"level\":\"Information\",\"timestamp\":\"2024-01-01T00:00:00.0000000\",\"logger\":{\"name\":\"AWS.Lambda.Powertools.Logging.Logger\",\"sample_rate\":0.2}}") ); -#else - consoleOut.Received(1).WriteLine( - Arg.Is(i => - i == - "{\"message\":\"test\",\"service\":\"my_service\",\"correlation_ids\":{\"aws_request_id\":null,\"x_ray_trace_id\":null,\"correlation_id\":null},\"lambda_function\":{\"name\":null,\"arn\":null,\"memory_limit_in_m_b\":null,\"version\":null,\"cold_start\":true},\"level\":\"Information\",\"timestamp\":\"2024-01-01T00:00:00.0000000\",\"logger\":{\"name\":\"AWS.Lambda.Powertools.Logging.Logger\",\"sample_rate\":0.2}}") - ); -#endif } public void Dispose() diff --git a/libraries/tests/AWS.Lambda.Powertools.Logging.Tests/Serializers/PowertoolsLambdaSerializerTests.cs b/libraries/tests/AWS.Lambda.Powertools.Logging.Tests/Serializers/PowertoolsLambdaSerializerTests.cs index b522963f9..489504927 100644 --- a/libraries/tests/AWS.Lambda.Powertools.Logging.Tests/Serializers/PowertoolsLambdaSerializerTests.cs +++ b/libraries/tests/AWS.Lambda.Powertools.Logging.Tests/Serializers/PowertoolsLambdaSerializerTests.cs @@ -30,7 +30,6 @@ namespace AWS.Lambda.Powertools.Logging.Tests.Serializers; public class PowertoolsLambdaSerializerTests : IDisposable { -#if NET8_0_OR_GREATER [Fact] public void Constructor_ShouldNotThrowException() { @@ -221,41 +220,10 @@ public void Should_Serialize_Unknown_Type_When_Including_Outside_Context() } -#endif public void Dispose() { PowertoolsLoggingSerializer.ConfigureNamingPolicy(LoggingConstants.DefaultLoggerOutputCase); PowertoolsLoggingSerializer.ClearOptions(); } -#if NET6_0 - - [Fact] - public void Should_Serialize_Net6() - { - // Arrange - PowertoolsLoggingSerializer.ConfigureNamingPolicy(LoggingConstants.DefaultLoggerOutputCase); - var testObject = new APIGatewayProxyRequest - { - Path = "asda", - RequestContext = new APIGatewayProxyRequest.ProxyRequestContext - { - RequestId = "asdas" - } - }; - - var log = new LogEntry - { - Name = "dasda", - Message = testObject - }; - - var outptuMySerializer = PowertoolsLoggingSerializer.Serialize(log, null); - - // Assert - Assert.Equal( - "{\"cold_start\":false,\"x_ray_trace_id\":null,\"correlation_id\":null,\"timestamp\":\"0001-01-01T00:00:00\",\"level\":\"Trace\",\"service\":null,\"name\":\"dasda\",\"message\":{\"resource\":null,\"path\":\"asda\",\"http_method\":null,\"headers\":null,\"multi_value_headers\":null,\"query_string_parameters\":null,\"multi_value_query_string_parameters\":null,\"path_parameters\":null,\"stage_variables\":null,\"request_context\":{\"path\":null,\"account_id\":null,\"resource_id\":null,\"stage\":null,\"request_id\":\"asdas\",\"identity\":null,\"resource_path\":null,\"http_method\":null,\"api_id\":null,\"extended_request_id\":null,\"connection_id\":null,\"connected_at\":0,\"domain_name\":null,\"domain_prefix\":null,\"event_type\":null,\"message_id\":null,\"route_key\":null,\"authorizer\":null,\"operation_name\":null,\"error\":null,\"integration_latency\":null,\"message_direction\":null,\"request_time\":null,\"request_time_epoch\":0,\"status\":null},\"body\":null,\"is_base64_encoded\":false},\"sampling_rate\":null,\"extra_keys\":null,\"exception\":null,\"lambda_context\":null}", - outptuMySerializer); - } -#endif } \ No newline at end of file diff --git a/libraries/tests/AWS.Lambda.Powertools.Logging.Tests/Serializers/PowertoolsLoggingSerializerTests.cs b/libraries/tests/AWS.Lambda.Powertools.Logging.Tests/Serializers/PowertoolsLoggingSerializerTests.cs index f8e1cd486..be5830777 100644 --- a/libraries/tests/AWS.Lambda.Powertools.Logging.Tests/Serializers/PowertoolsLoggingSerializerTests.cs +++ b/libraries/tests/AWS.Lambda.Powertools.Logging.Tests/Serializers/PowertoolsLoggingSerializerTests.cs @@ -35,9 +35,7 @@ public class PowertoolsLoggingSerializerTests : IDisposable public PowertoolsLoggingSerializerTests() { PowertoolsLoggingSerializer.ConfigureNamingPolicy(LoggingConstants.DefaultLoggerOutputCase); -#if NET8_0_OR_GREATER PowertoolsLoggingSerializer.ClearContext(); -#endif } [Fact] @@ -61,18 +59,12 @@ public void SerializerOptions_ShouldHaveCorrectDefaultSettings() converter => Assert.IsType(converter), converter => Assert.IsType(converter), converter => Assert.IsType(converter), -#if NET8_0_OR_GREATER converter => Assert.IsType(converter)); -#elif NET6_0 - converter => Assert.IsType(converter)); -#endif Assert.Equal(JavaScriptEncoder.UnsafeRelaxedJsonEscaping, options.Encoder); -#if NET8_0_OR_GREATER Assert.Collection(options.TypeInfoResolverChain, resolver => Assert.IsType(resolver)); -#endif } [Fact] @@ -89,17 +81,11 @@ public void SerializerOptions_ShouldHaveCorrectDefaultSettings_WhenDynamic() converter => Assert.IsType(converter), converter => Assert.IsType(converter), converter => Assert.IsType(converter), -#if NET8_0_OR_GREATER - converter => Assert.IsType(converter)); -#elif NET6_0 converter => Assert.IsType(converter)); -#endif Assert.Equal(JavaScriptEncoder.UnsafeRelaxedJsonEscaping, options.Encoder); -#if NET8_0_OR_GREATER Assert.Empty(options.TypeInfoResolverChain); -#endif } [Fact] @@ -167,7 +153,6 @@ public void Serialize_ShouldHandleEnumValues() Assert.Contains("\"level\":\"Error\"", json); } -#if NET8_0_OR_GREATER [Fact] public void Serialize_UnknownType_ThrowsInvalidOperationException() { @@ -201,7 +186,6 @@ private class UnknownType { public string SomeProperty { get; set; } } -#endif private string SerializeTestObject(LoggerOutputCase? outputCase) { @@ -217,9 +201,7 @@ private string SerializeTestObject(LoggerOutputCase? outputCase) public void Dispose() { PowertoolsLoggingSerializer.ConfigureNamingPolicy(LoggingConstants.DefaultLoggerOutputCase); -#if NET8_0_OR_GREATER PowertoolsLoggingSerializer.ClearContext(); -#endif PowertoolsLoggingSerializer.ClearOptions(); RuntimeFeatureWrapper.Reset(); } diff --git a/libraries/tests/AWS.Lambda.Powertools.Logging.Tests/Utilities/PowertoolsLoggerHelpersTests.cs b/libraries/tests/AWS.Lambda.Powertools.Logging.Tests/Utilities/PowertoolsLoggerHelpersTests.cs index 399792a5c..da3dd6968 100644 --- a/libraries/tests/AWS.Lambda.Powertools.Logging.Tests/Utilities/PowertoolsLoggerHelpersTests.cs +++ b/libraries/tests/AWS.Lambda.Powertools.Logging.Tests/Utilities/PowertoolsLoggerHelpersTests.cs @@ -1,5 +1,3 @@ -#if NET8_0_OR_GREATER - using System; using System.Collections.Generic; using System.IO; @@ -205,5 +203,3 @@ public void Dispose() PowertoolsLoggingSerializer.ClearOptions(); } } - -#endif \ No newline at end of file diff --git a/libraries/tests/AWS.Lambda.Powertools.Tracing.Tests/Serializers/PowertoolsTracingSerializerTests.cs b/libraries/tests/AWS.Lambda.Powertools.Tracing.Tests/Serializers/PowertoolsTracingSerializerTests.cs index 988cbab5a..be4f12373 100644 --- a/libraries/tests/AWS.Lambda.Powertools.Tracing.Tests/Serializers/PowertoolsTracingSerializerTests.cs +++ b/libraries/tests/AWS.Lambda.Powertools.Tracing.Tests/Serializers/PowertoolsTracingSerializerTests.cs @@ -13,7 +13,6 @@ * permissions and limitations under the License. */ -#if NET8_0_OR_GREATER using System; using System.Collections.Generic; using System.Text.Json; @@ -251,5 +250,4 @@ public class TestNullableObject public class TestArrayObject { public int[] Values { get; set; } -} -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/libraries/tests/AWS.Lambda.Powertools.Tracing.Tests/Serializers/TestJsonContext.cs b/libraries/tests/AWS.Lambda.Powertools.Tracing.Tests/Serializers/TestJsonContext.cs index b1a8226d0..81d9287bd 100644 --- a/libraries/tests/AWS.Lambda.Powertools.Tracing.Tests/Serializers/TestJsonContext.cs +++ b/libraries/tests/AWS.Lambda.Powertools.Tracing.Tests/Serializers/TestJsonContext.cs @@ -13,8 +13,6 @@ * permissions and limitations under the License. */ -#if NET8_0_OR_GREATER - using System.Collections.Generic; using System.Text.Json.Serialization; @@ -43,7 +41,6 @@ public class TestComplexObject public Dictionary NestedObject { get; set; } } -#endif public class TestResponse { diff --git a/libraries/tests/AWS.Lambda.Powertools.Tracing.Tests/Serializers/TracingSerializerExtensionsTests.cs b/libraries/tests/AWS.Lambda.Powertools.Tracing.Tests/Serializers/TracingSerializerExtensionsTests.cs index 72fe92b46..999143a43 100644 --- a/libraries/tests/AWS.Lambda.Powertools.Tracing.Tests/Serializers/TracingSerializerExtensionsTests.cs +++ b/libraries/tests/AWS.Lambda.Powertools.Tracing.Tests/Serializers/TracingSerializerExtensionsTests.cs @@ -14,7 +14,6 @@ */ -#if NET8_0_OR_GREATER using Amazon.Lambda.Serialization.SystemTextJson; using AWS.Lambda.Powertools.Tracing.Serializers; using Xunit; @@ -40,5 +39,4 @@ public void WithTracing_InitializesSerializer_Successfully() var serialized = PowertoolsTracingSerializer.Serialize(testObject); Assert.Contains("\"Name\":\"Test\"", serialized); } -} -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/libraries/tests/AWS.Lambda.Powertools.Tracing.Tests/TracingAspectTests.cs b/libraries/tests/AWS.Lambda.Powertools.Tracing.Tests/TracingAspectTests.cs index e638a35d3..e373278e2 100644 --- a/libraries/tests/AWS.Lambda.Powertools.Tracing.Tests/TracingAspectTests.cs +++ b/libraries/tests/AWS.Lambda.Powertools.Tracing.Tests/TracingAspectTests.cs @@ -23,10 +23,8 @@ using NSubstitute; using Xunit; -#if NET8_0_OR_GREATER using AWS.Lambda.Powertools.Tracing.Serializers; using AWS.Lambda.Powertools.Tracing.Tests.Serializers; -#endif namespace AWS.Lambda.Powertools.Tracing.Tests; @@ -113,7 +111,6 @@ public async Task Around_AsyncMethod_HandlesResponseAndSegmentCorrectly() _mockXRayRecorder.Received(1).EndSubsegment(); } -#if NET8_0_OR_GREATER [Fact] public void Around_SyncMethod_HandlesResponseAndSegmentCorrectly_AOT() { @@ -177,7 +174,6 @@ public async Task Around_AsyncMethod_HandlesResponseAndSegmentCorrectly_AOT() PowertoolsTracingSerializer.Serialize(result)); _mockXRayRecorder.Received(1).EndSubsegment(); } -#endif [Fact] public async Task Around_VoidAsyncMethod_HandlesSegmentCorrectly() diff --git a/libraries/tests/Directory.Build.props b/libraries/tests/Directory.Build.props index d662fc454..26ab08bb9 100644 --- a/libraries/tests/Directory.Build.props +++ b/libraries/tests/Directory.Build.props @@ -1,6 +1,6 @@ - net6.0;net8.0 + net8.0 false diff --git a/libraries/tests/e2e/functions/core/logging/Function/src/Function/Function.csproj b/libraries/tests/e2e/functions/core/logging/Function/src/Function/Function.csproj index 2e08d5e4a..80be7fd59 100644 --- a/libraries/tests/e2e/functions/core/logging/Function/src/Function/Function.csproj +++ b/libraries/tests/e2e/functions/core/logging/Function/src/Function/Function.csproj @@ -1,6 +1,6 @@ - net6.0;net8.0 + net8.0 enable enable true diff --git a/libraries/tests/e2e/functions/core/metrics/Function/src/Function/Function.csproj b/libraries/tests/e2e/functions/core/metrics/Function/src/Function/Function.csproj index 1664858ed..ed95bbca4 100644 --- a/libraries/tests/e2e/functions/core/metrics/Function/src/Function/Function.csproj +++ b/libraries/tests/e2e/functions/core/metrics/Function/src/Function/Function.csproj @@ -1,6 +1,6 @@ - net6.0;net8.0 + net8.0 enable enable true diff --git a/libraries/tests/e2e/functions/core/tracing/Function/src/Function/Function.csproj b/libraries/tests/e2e/functions/core/tracing/Function/src/Function/Function.csproj index c8c004582..e8d65b046 100644 --- a/libraries/tests/e2e/functions/core/tracing/Function/src/Function/Function.csproj +++ b/libraries/tests/e2e/functions/core/tracing/Function/src/Function/Function.csproj @@ -1,6 +1,6 @@ - net6.0;net8.0 + net8.0 enable enable true diff --git a/libraries/tests/e2e/functions/idempotency/Function/src/Function/Function.csproj b/libraries/tests/e2e/functions/idempotency/Function/src/Function/Function.csproj index 0dedeaeab..827690848 100644 --- a/libraries/tests/e2e/functions/idempotency/Function/src/Function/Function.csproj +++ b/libraries/tests/e2e/functions/idempotency/Function/src/Function/Function.csproj @@ -1,6 +1,6 @@ - net6.0;net8.0 + net8.0 enable enable true