Skip to content

Commit b2b0d25

Browse files
committed
chore: drop .NET 6 support, go .NET 8 only
- removed all net6.0 target frameworks - cleaned up conditional compilation blocks - simplified code by removing version checks - updated e2e tests to only use net8.0 functions fixes #749
1 parent 1dfab3c commit b2b0d25

File tree

45 files changed

+19
-304
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+19
-304
lines changed

libraries/src/AWS.Lambda.Powertools.Idempotency/Idempotency.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,8 @@ public IdempotencyBuilder WithOptions(IdempotencyOptions options)
166166
return this;
167167
}
168168

169-
#if NET8_0_OR_GREATER
170169
/// <summary>
171-
/// Set Customer JsonSerializerContext to append to IdempotencySerializationContext
170+
/// Set Customer JsonSerializerContext to append to IdempotencySerializationContext
172171
/// </summary>
173172
/// <param name="context"></param>
174173
/// <returns>IdempotencyBuilder</returns>
@@ -177,6 +176,5 @@ public IdempotencyBuilder WithJsonSerializationContext(JsonSerializerContext con
177176
IdempotencySerializer.AddTypeInfoResolver(context);
178177
return this;
179178
}
180-
#endif
181179
}
182180
}

libraries/src/AWS.Lambda.Powertools.Idempotency/IdempotencyOptionsBuilder.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,15 +160,9 @@ public IdempotencyOptionsBuilder WithExpiration(TimeSpan duration)
160160
/// </summary>
161161
/// <param name="hashFunction">Can be any algorithm supported by HashAlgorithm.Create</param>
162162
/// <returns>the instance of the builder (to chain operations)</returns>
163-
#if NET8_0_OR_GREATER
164163
[Obsolete("Idempotency uses MD5 and does not support other hash algorithms.")]
165-
#endif
166164
public IdempotencyOptionsBuilder WithHashFunction(string hashFunction)
167165
{
168-
#if NET6_0
169-
// for backward compability keep this code in .net 6
170-
_hashFunction = hashFunction;
171-
#endif
172166
return this;
173167
}
174168

libraries/src/AWS.Lambda.Powertools.Idempotency/Internal/Serializers/IdempotencySerializationContext.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,12 @@
1717

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

20-
#if NET8_0_OR_GREATER
21-
22-
2320
/// <summary>
24-
/// The source generated JsonSerializerContext to be used to Serialize Idempotency types
21+
/// The source generated JsonSerializerContext to be used to Serialize Idempotency types
2522
/// </summary>
2623
[JsonSerializable(typeof(string))]
2724
[JsonSerializable(typeof(object))]
2825
public partial class IdempotencySerializationContext : JsonSerializerContext
2926
{
3027

31-
}
32-
#endif
28+
}

libraries/src/AWS.Lambda.Powertools.Idempotency/Internal/Serializers/IdempotencySerializer.cs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,12 @@ private static void BuildDefaultOptions()
2929
{
3030
PropertyNameCaseInsensitive = true
3131
};
32-
#if NET8_0_OR_GREATER
3332
if (!RuntimeFeatureWrapper.IsDynamicCodeSupported)
3433
{
3534
_jsonOptions.TypeInfoResolverChain.Add(IdempotencySerializationContext.Default);
3635
}
37-
#endif
3836
}
3937

40-
#if NET8_0_OR_GREATER
41-
4238
/// <summary>
4339
/// Adds a JsonTypeInfoResolver to the JsonSerializerOptions.
4440
/// </summary>
@@ -73,7 +69,6 @@ internal static void SetJsonOptions(JsonSerializerOptions options)
7369
{
7470
_jsonOptions = options;
7571
}
76-
#endif
7772

7873
/// <summary>
7974
/// Serializes the specified object to a JSON string.
@@ -83,9 +78,6 @@ internal static void SetJsonOptions(JsonSerializerOptions options)
8378
/// <returns>A JSON string representation of the object.</returns>
8479
internal static string Serialize(object value, Type inputType)
8580
{
86-
#if NET6_0
87-
return JsonSerializer.Serialize(value, _jsonOptions);
88-
#else
8981
if (RuntimeFeatureWrapper.IsDynamicCodeSupported)
9082
{
9183
#pragma warning disable
@@ -100,7 +92,6 @@ internal static string Serialize(object value, Type inputType)
10092
}
10193

10294
return JsonSerializer.Serialize(value, typeInfo);
103-
#endif
10495
}
10596

10697
/// <summary>
@@ -113,15 +104,11 @@ internal static string Serialize(object value, Type inputType)
113104
[UnconditionalSuppressMessage("AOT", "IL3050:Calling members annotated with 'RequiresDynamicCodeAttribute' may break functionality when AOT compiling.", Justification = "False positive")]
114105
internal static T Deserialize<T>(string value)
115106
{
116-
#if NET6_0
117-
return JsonSerializer.Deserialize<T>(value,_jsonOptions);
118-
#else
119107
if (RuntimeFeatureWrapper.IsDynamicCodeSupported)
120108
{
121109
return JsonSerializer.Deserialize<T>(value, _jsonOptions);
122110
}
123111

124112
return (T)JsonSerializer.Deserialize(value, GetTypeInfo(typeof(T)));
125-
#endif
126113
}
127114
}

libraries/src/AWS.Lambda.Powertools.Idempotency/Persistence/BasePersistenceStore.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -324,12 +324,8 @@ private static bool IsMissingIdempotencyKey(JsonElement data)
324324
/// <exception cref="ArgumentException"></exception>
325325
internal string GenerateHash(JsonElement data)
326326
{
327-
#if NET8_0_OR_GREATER
328327
// starting .NET 8 no option to change hash algorithm
329328
using var hashAlgorithm = MD5.Create();
330-
#else
331-
using var hashAlgorithm = HashAlgorithm.Create(_idempotencyOptions.HashFunction);
332-
#endif
333329
if (hashAlgorithm == null)
334330
{
335331
throw new ArgumentException("Invalid HashAlgorithm");

libraries/src/AWS.Lambda.Powertools.JMESPath/Serializers/JMESPathSerializationContext.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
namespace AWS.Lambda.Powertools.JMESPath.Serializers;
55

6-
#if NET8_0_OR_GREATER
7-
86
/// <summary>
97
/// The source generated JsonSerializerContext to be used to Serialize JMESPath types
108
/// </summary>
@@ -16,6 +14,4 @@ namespace AWS.Lambda.Powertools.JMESPath.Serializers;
1614
[JsonSerializable(typeof(JsonElement))]
1715
public partial class JmesPathSerializationContext : JsonSerializerContext
1816
{
19-
}
20-
21-
#endif
17+
}

libraries/src/AWS.Lambda.Powertools.JMESPath/Serializers/JMESPathSerializer.cs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,7 @@ internal static class JmesPathSerializer
1616
/// <returns>System.String.</returns>
1717
internal static string Serialize(object value, Type inputType)
1818
{
19-
#if NET6_0
20-
return JsonSerializer.Serialize(value);
21-
#else
22-
2319
return JsonSerializer.Serialize(value, inputType, JmesPathSerializationContext.Default);
24-
#endif
2520
}
2621

2722
/// <summary>
@@ -32,11 +27,6 @@ internal static string Serialize(object value, Type inputType)
3227
/// <returns>T.</returns>
3328
internal static T Deserialize<T>(string value)
3429
{
35-
#if NET6_0
36-
return JsonSerializer.Deserialize<T>(value);
37-
#else
38-
3930
return (T)JsonSerializer.Deserialize(value, typeof(T), JmesPathSerializationContext.Default);
40-
#endif
4131
}
4232
}

libraries/src/AWS.Lambda.Powertools.Logging/Internal/PowertoolsLogger.cs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -397,11 +397,7 @@ private object GetFormattedLogEntry(LogLevel logLevel, DateTime timestamp, objec
397397
if (logObject is null)
398398
throw new LogFormatException($"{logFormatter.GetType().FullName} returned Null value.");
399399

400-
#if NET8_0_OR_GREATER
401400
return PowertoolsLoggerHelpers.ObjectToDictionary(logObject);
402-
#else
403-
return logObject;
404-
#endif
405401
}
406402
catch (Exception e)
407403
{
@@ -425,7 +421,6 @@ private static bool CustomFormatter<TState>(TState state, Exception exception, o
425421
if (exception is not null)
426422
return false;
427423

428-
#if NET8_0_OR_GREATER
429424
var stateKeys = new Dictionary<string, object>();
430425
if (state is IEnumerable<KeyValuePair<string, object>> keyValuePairs)
431426
{
@@ -434,16 +429,6 @@ private static bool CustomFormatter<TState>(TState state, Exception exception, o
434429
stateKeys[kvp.Key] = PowertoolsLoggerHelpers.ObjectToDictionary(kvp.Value);
435430
}
436431
}
437-
#else
438-
var stateKeys = new Dictionary<string, object>();
439-
if (state is IEnumerable<KeyValuePair<string, object>> keyValuePairs)
440-
{
441-
foreach (var kvp in keyValuePairs)
442-
{
443-
stateKeys[kvp.Key] = kvp.Value;
444-
}
445-
}
446-
#endif
447432

448433
if (stateKeys.Count != 2)
449434
return false;

libraries/src/AWS.Lambda.Powertools.Logging/Logger.Scope.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,8 @@ public static void AppendKey(string key, object value)
2525
if (string.IsNullOrWhiteSpace(key))
2626
throw new ArgumentNullException(nameof(key));
2727

28-
#if NET8_0_OR_GREATER
2928
Scope[key] = PowertoolsLoggerHelpers.ObjectToDictionary(value) ??
3029
throw new ArgumentNullException(nameof(value));
31-
#else
32-
Scope[key] = value ?? throw new ArgumentNullException(nameof(value));
33-
#endif
3430
}
3531

3632
/// <summary>

libraries/src/AWS.Lambda.Powertools.Logging/Serializers/CompositeJsonTypeInfoResolver.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#if NET8_0_OR_GREATER
2-
31
using System;
42
using System.Text.Json;
53
using System.Text.Json.Serialization.Metadata;
@@ -40,5 +38,4 @@ public JsonTypeInfo GetTypeInfo(Type type, JsonSerializerOptions options)
4038
return null;
4139
}
4240
}
43-
}
44-
#endif
41+
}

0 commit comments

Comments
 (0)