Skip to content

Commit

Permalink
🐛 fix(TypeAdapter.cs): make source parameter nullable
Browse files Browse the repository at this point in the history
The source parameter in the Adapt method is now nullable, which allows for null values to be passed in without throwing a null reference exception. This improves the robustness of the code and makes it more defensive against unexpected null values.
  • Loading branch information
msadeqsirjani committed Apr 22, 2023
1 parent 862bc8b commit b4daba7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Mapster/TypeAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public static TypeAdapterBuilder<TSource> BuildAdapter<TSource>(this TSource sou
/// <typeparam name="TDestination">Destination type.</typeparam>
/// <param name="source">Source object to adapt.</param>
/// <returns>Adapted destination type.</returns>
public static TDestination Adapt<TDestination>(this object source)
public static TDestination Adapt<TDestination>(this object? source)
{
return Adapt<TDestination>(source, TypeAdapterConfig.GlobalSettings);
}
Expand All @@ -33,7 +33,7 @@ public static TDestination Adapt<TDestination>(this object source)
/// <param name="source">Source object to adapt.</param>
/// <param name="config">Configuration</param>
/// <returns>Adapted destination type.</returns>
public static TDestination Adapt<TDestination>(this object source, TypeAdapterConfig config)
public static TDestination Adapt<TDestination>(this object? source, TypeAdapterConfig config)
{
// ReSharper disable once ConditionIsAlwaysTrueOrFalse
if (source == null)
Expand Down

0 comments on commit b4daba7

Please sign in to comment.