diff --git a/CHANGELOG.md b/CHANGELOG.md
index e2b7838..899eb7c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -9,6 +9,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
+## [1.1.2] - 2024-01-30
+
+### Changed
+
+- Fixed some AOT warnings due to reflection use on enum types.
+
## [1.1.1] - 2023-11-15
### Added
diff --git a/src/FormParseNode.cs b/src/FormParseNode.cs
index 9376507..6a17b23 100644
--- a/src/FormParseNode.cs
+++ b/src/FormParseNode.cs
@@ -24,12 +24,12 @@ public FormParseNode(string rawValue)
Fields = rawValue.Split(new char[] {'&'}, StringSplitOptions.RemoveEmptyEntries)
.Select(static x => x.Split(new char[] {'='}, StringSplitOptions.RemoveEmptyEntries))
.Where(static x => x.Length == 2)
- .Select(static x => (key: sanitizeKey(x[0]), value: x[1].Trim()))
+ .Select(static x => (key: SanitizeKey(x[0]), value: x[1].Trim()))
.GroupBy(static x => x.key, StringComparer.OrdinalIgnoreCase)
.Select(static x => (key: x.Key, value: string.Join(",", x.Select(static y => y.value))))
.ToDictionary(static x => x.key, static x => x.value, StringComparer.OrdinalIgnoreCase);
}
- private static string sanitizeKey(string key) {
+ private static string SanitizeKey(string key) {
if (string.IsNullOrEmpty(key)) return key;
return Uri.UnescapeDataString(key.Trim());
}
@@ -48,7 +48,7 @@ private static string sanitizeKey(string key) {
///
public byte? GetByteValue() => byte.TryParse(DecodedValue, out var result) ? result : null;
///
- public IParseNode? GetChildNode(string identifier) => Fields.TryGetValue(sanitizeKey(identifier), out var value) ? new FormParseNode(value) : null;
+ public IParseNode? GetChildNode(string identifier) => Fields.TryGetValue(SanitizeKey(identifier), out var value) ? new FormParseNode(value) : null;
///
public IEnumerable GetCollectionOfObjectValues(ParsableFactory factory) where T : IParsable => throw new InvalidOperationException("collections are not supported with uri form encoding");
@@ -141,8 +141,7 @@ private void AssignFieldValues(T item) where T : IParsable
IDictionary? itemAdditionalData = null;
if(item is IAdditionalDataHolder holder)
{
- if(holder.AdditionalData == null)
- holder.AdditionalData = new Dictionary();
+ holder.AdditionalData ??= new Dictionary();
itemAdditionalData = holder.AdditionalData;
}
var fieldDeserializers = item.GetFieldDeserializers();
diff --git a/src/FormSerializationWriter.cs b/src/FormSerializationWriter.cs
index 7a46f38..624e8cb 100644
--- a/src/FormSerializationWriter.cs
+++ b/src/FormSerializationWriter.cs
@@ -97,7 +97,7 @@ public void WriteBoolValue(string? key, bool? value) {
///
public void WriteByteArrayValue(string? key, byte[]? value) {
if(value != null)//empty array is meaningful
- WriteStringValue(key, value.Any() ? Convert.ToBase64String(value) : string.Empty);
+ WriteStringValue(key, value.Length > 0 ? Convert.ToBase64String(value) : string.Empty);
}
///
public void WriteByteValue(string? key, byte? value) {
@@ -109,7 +109,7 @@ public void WriteByteValue(string? key, byte? value) {
///
public void WriteCollectionOfPrimitiveValues(string? key, IEnumerable? values)
{
- if(values == null || !values.Any()) return;
+ if(values == null) return;
foreach(var value in values.Where(static x => x != null))
WriteAnyValue(key,value!);
}
@@ -201,7 +201,7 @@ public void WriteTimeValue(string? key, Time? value) {
}
///
#if NET5_0_OR_GREATER
- public void WriteCollectionOfEnumValues<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)]T>(string? key, IEnumerable? values) where T : struct, Enum
+ public void WriteCollectionOfEnumValues<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicFields)] T>(string? key, IEnumerable? values) where T : struct, Enum
#else
public void WriteCollectionOfEnumValues(string? key, IEnumerable? values) where T : struct, Enum
#endif
@@ -212,7 +212,7 @@ public void WriteCollectionOfEnumValues(string? key, IEnumerable? values)
}
///
#if NET5_0_OR_GREATER
- public void WriteEnumValue<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)]T>(string? key, T? value) where T : struct, Enum
+ public void WriteEnumValue<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicFields)] T>(string? key, T? value) where T : struct, Enum
#else
public void WriteEnumValue(string? key, T? value) where T : struct, Enum
#endif
@@ -220,7 +220,12 @@ public void WriteEnumValue(string? key, T? value) where T : struct, Enum
if(value.HasValue)
{
if(typeof(T).GetCustomAttributes().Any())
- WriteStringValue(key, string.Join(",", Enum.GetValues(typeof(T))
+ WriteStringValue(key, string.Join(",",
+#if NET5_0_OR_GREATER
+ Enum.GetValues()
+#else
+ Enum.GetValues(typeof(T))
+#endif
.Cast()
.Where(x => value.Value.HasFlag(x))
.Select(static x => Enum.GetName(typeof(T),x))
diff --git a/src/Microsoft.Kiota.Serialization.Form.csproj b/src/Microsoft.Kiota.Serialization.Form.csproj
index 3d10c17..530ebce 100644
--- a/src/Microsoft.Kiota.Serialization.Form.csproj
+++ b/src/Microsoft.Kiota.Serialization.Form.csproj
@@ -16,7 +16,7 @@
https://aka.ms/kiota/docs
true
true
- 1.1.1
+ 1.1.2
true
true