Skip to content
Merged
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
7 changes: 3 additions & 4 deletions Tomlet/TomlSerializationMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -371,14 +371,13 @@
};
}

// unmanaged + IConvertible is the closest I can get to expressing "primitives only"
#if MODERN_DOTNET
#if NET7_0_OR_GREATER
[RequiresDynamicCode("The native code for underlying implementations of deserialize helper methods may not be available for a given type.")]
#endif // NET7_0_OR_GREATER
private static Deserialize<Dictionary<TKey, TValue>> PrimitiveKeyedDictionaryDeserializerFor<TKey, [DynamicallyAccessedMembers(MainDeserializerAccessedMemberTypes)] TValue>(TomlSerializerOptions options) where TKey : unmanaged, IConvertible
private static Deserialize<Dictionary<TKey, TValue>> PrimitiveKeyedDictionaryDeserializerFor<TKey, [DynamicallyAccessedMembers(MainDeserializerAccessedMemberTypes)] TValue>(TomlSerializerOptions options)

Check warning on line 378 in Tomlet/TomlSerializationMethods.cs

View workflow job for this annotation

GitHub Actions / build

The type 'TKey' cannot be used as type parameter 'TKey' in the generic type or method 'Dictionary<TKey, TValue>'. Nullability of type argument 'TKey' doesn't match 'notnull' constraint.

Check warning on line 378 in Tomlet/TomlSerializationMethods.cs

View workflow job for this annotation

GitHub Actions / build

The type 'TKey' cannot be used as type parameter 'TKey' in the generic type or method 'Dictionary<TKey, TValue>'. Nullability of type argument 'TKey' doesn't match 'notnull' constraint.

Check warning on line 378 in Tomlet/TomlSerializationMethods.cs

View workflow job for this annotation

GitHub Actions / build

The type 'TKey' cannot be used as type parameter 'TKey' in the generic type or method 'Dictionary<TKey, TValue>'. Nullability of type argument 'TKey' doesn't match 'notnull' constraint.

Check warning on line 378 in Tomlet/TomlSerializationMethods.cs

View workflow job for this annotation

GitHub Actions / build

The type 'TKey' cannot be used as type parameter 'TKey' in the generic type or method 'Dictionary<TKey, TValue>'. Nullability of type argument 'TKey' doesn't match 'notnull' constraint.
#else
private static Deserialize<Dictionary<TKey, TValue>> PrimitiveKeyedDictionaryDeserializerFor<TKey, TValue>(TomlSerializerOptions options) where TKey : unmanaged, IConvertible
private static Deserialize<Dictionary<TKey, TValue>> PrimitiveKeyedDictionaryDeserializerFor<TKey, TValue>(TomlSerializerOptions options)
#endif
{
var valueDeserializer = GetDeserializer(typeof(TValue), options);
Expand All @@ -386,9 +385,9 @@
return value =>
{
if (value is not TomlTable table)
throw new TomlTypeMismatchException(typeof(TomlTable), value.GetType(), typeof(Dictionary<TKey, TValue>));

Check warning on line 388 in Tomlet/TomlSerializationMethods.cs

View workflow job for this annotation

GitHub Actions / build

The type 'TKey' cannot be used as type parameter 'TKey' in the generic type or method 'Dictionary<TKey, TValue>'. Nullability of type argument 'TKey' doesn't match 'notnull' constraint.

Check warning on line 388 in Tomlet/TomlSerializationMethods.cs

View workflow job for this annotation

GitHub Actions / build

The type 'TKey' cannot be used as type parameter 'TKey' in the generic type or method 'Dictionary<TKey, TValue>'. Nullability of type argument 'TKey' doesn't match 'notnull' constraint.

Check warning on line 388 in Tomlet/TomlSerializationMethods.cs

View workflow job for this annotation

GitHub Actions / build

The type 'TKey' cannot be used as type parameter 'TKey' in the generic type or method 'Dictionary<TKey, TValue>'. Nullability of type argument 'TKey' doesn't match 'notnull' constraint.

return table.Entries

Check warning on line 390 in Tomlet/TomlSerializationMethods.cs

View workflow job for this annotation

GitHub Actions / build

The type 'TKey' cannot be used as type parameter 'TKey' in the generic type or method 'Enumerable.ToDictionary<TSource, TKey, TElement>(IEnumerable<TSource>, Func<TSource, TKey>, Func<TSource, TElement>)'. Nullability of type argument 'TKey' doesn't match 'notnull' constraint.

Check warning on line 390 in Tomlet/TomlSerializationMethods.cs

View workflow job for this annotation

GitHub Actions / build

The type 'TKey' cannot be used as type parameter 'TKey' in the generic type or method 'Enumerable.ToDictionary<TSource, TKey, TElement>(IEnumerable<TSource>, Func<TSource, TKey>, Func<TSource, TElement>)'. Nullability of type argument 'TKey' doesn't match 'notnull' constraint.

Check warning on line 390 in Tomlet/TomlSerializationMethods.cs

View workflow job for this annotation

GitHub Actions / build

The type 'TKey' cannot be used as type parameter 'TKey' in the generic type or method 'Enumerable.ToDictionary<TSource, TKey, TElement>(IEnumerable<TSource>, Func<TSource, TKey>, Func<TSource, TElement>)'. Nullability of type argument 'TKey' doesn't match 'notnull' constraint.
.Where(entry =>
{
if (!type.IsEnum || !options.IgnoreInvalidEnumValues)
Expand Down Expand Up @@ -539,4 +538,4 @@
.ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
});
}
}
}
Loading