Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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):

Expand Down Expand Up @@ -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/)**
Expand Down
2 changes: 1 addition & 1 deletion docs/core/tracing.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 4 additions & 4 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"}.
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion docs/roadmap.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion examples/BatchProcessing/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
2 changes: 1 addition & 1 deletion examples/Idempotency/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
2 changes: 1 addition & 1 deletion examples/Logging/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
2 changes: 1 addition & 1 deletion examples/Metrics/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
2 changes: 1 addition & 1 deletion examples/Parameters/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
2 changes: 1 addition & 1 deletion examples/ServerlessApi/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
2 changes: 1 addition & 1 deletion examples/Tracing/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ public IdempotencyBuilder WithOptions(IdempotencyOptions options)
return this;
}

#if NET8_0_OR_GREATER
/// <summary>
/// Set Customer JsonSerializerContext to append to IdempotencySerializationContext
/// </summary>
Expand All @@ -192,6 +191,5 @@ public IdempotencyBuilder WithJsonSerializationContext(JsonSerializerContext con
IdempotencySerializer.AddTypeInfoResolver(context);
return this;
}
#endif
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -122,15 +122,9 @@ public IdempotencyOptionsBuilder WithExpiration(TimeSpan duration)
/// </summary>
/// <param name="hashFunction">Can be any algorithm supported by HashAlgorithm.Create</param>
/// <returns>the instance of the builder (to chain operations)</returns>
#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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@

namespace AWS.Lambda.Powertools.Idempotency.Internal.Serializers;

#if NET8_0_OR_GREATER


/// <summary>
/// The source generated JsonSerializerContext to be used to Serialize Idempotency types
Expand All @@ -28,5 +26,4 @@ namespace AWS.Lambda.Powertools.Idempotency.Internal.Serializers;
public partial class IdempotencySerializationContext : JsonSerializerContext
{

}
#endif
}
Original file line number Diff line number Diff line change
Expand Up @@ -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

/// <summary>
/// Adds a JsonTypeInfoResolver to the JsonSerializerOptions.
/// </summary>
/// <param name="context">The JsonTypeInfoResolver to add.</param>
/// <remarks>
/// This method is only available in .NET 8.0 and later versions.
/// This method is available in .NET 8.0 and later versions.
/// </remarks>
internal static void AddTypeInfoResolver(JsonSerializerContext context)
{
Expand Down Expand Up @@ -88,7 +84,6 @@ internal static void SetJsonOptions(JsonSerializerOptions options)
{
_jsonOptions = options;
}
#endif

/// <summary>
/// Serializes the specified object to a JSON string.
Expand All @@ -98,9 +93,6 @@ internal static void SetJsonOptions(JsonSerializerOptions options)
/// <returns>A JSON string representation of the object.</returns>
internal static string Serialize(object value, Type inputType)
{
#if NET6_0
return JsonSerializer.Serialize(value, _jsonOptions);
#else
if (RuntimeFeatureWrapper.IsDynamicCodeSupported)
{
#pragma warning disable
Expand All @@ -115,7 +107,6 @@ internal static string Serialize(object value, Type inputType)
}

return JsonSerializer.Serialize(value, typeInfo);
#endif
}

/// <summary>
Expand All @@ -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<T>(string value)
{
#if NET6_0
return JsonSerializer.Deserialize<T>(value,_jsonOptions);
#else
if (RuntimeFeatureWrapper.IsDynamicCodeSupported)
{
return JsonSerializer.Deserialize<T>(value, _jsonOptions);
}

return (T)JsonSerializer.Deserialize(value, GetTypeInfo(typeof(T)));
#endif
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -339,12 +339,8 @@ private static bool IsMissingIdempotencyKey(JsonElement data)
/// <exception cref="ArgumentException"></exception>
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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@

namespace AWS.Lambda.Powertools.JMESPath.Serializers;

#if NET8_0_OR_GREATER

/// <summary>
/// The source generated JsonSerializerContext to be used to Serialize JMESPath types
/// </summary>
Expand All @@ -32,5 +30,3 @@ namespace AWS.Lambda.Powertools.JMESPath.Serializers;
public partial class JmesPathSerializationContext : JsonSerializerContext
{
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,7 @@ internal static class JmesPathSerializer
/// <returns>System.String.</returns>
internal static string Serialize(object value, Type inputType)
{
#if NET6_0
return JsonSerializer.Serialize(value);
#else

return JsonSerializer.Serialize(value, inputType, JmesPathSerializationContext.Default);
#endif
}

/// <summary>
Expand All @@ -47,11 +42,6 @@ internal static string Serialize(object value, Type inputType)
/// <returns>T.</returns>
internal static T Deserialize<T>(string value)
{
#if NET6_0
return JsonSerializer.Deserialize<T>(value);
#else

return (T)JsonSerializer.Deserialize(value, typeof(T), JmesPathSerializationContext.Default);
#endif
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -289,13 +285,8 @@ private static bool CustomFormatter<TState>(TState state, Exception exception, o
if (exception is not null)
return false;

#if NET8_0_OR_GREATER
var stateKeys = (state as IEnumerable<KeyValuePair<string, object>>)?
.ToDictionary(i => i.Key, i => PowertoolsLoggerHelpers.ObjectToDictionary(i.Value));
#else
var stateKeys = (state as IEnumerable<KeyValuePair<string, object>>)?
.ToDictionary(i => i.Key, i => i.Value);
#endif

if (stateKeys is null || stateKeys.Count != 2)
return false;
Expand Down
4 changes: 0 additions & 4 deletions libraries/src/AWS.Lambda.Powertools.Logging/Logger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@

namespace AWS.Lambda.Powertools.Logging.Serializers;

#if NET8_0_OR_GREATER

/// <summary>
/// Custom JSON serializer context for AWS.Lambda.Powertools.Logging
/// </summary>
Expand All @@ -44,5 +42,3 @@ public partial class PowertoolsLoggingSerializationContext : JsonSerializerConte
{
}


#endif
Loading
Loading