-
-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
StoreToDisk :IsDefaultValue emits wrong
- Loading branch information
1 parent
cf86e4c
commit 03d6737
Showing
10 changed files
with
61 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System; | ||
|
||
namespace Xpand.Extensions.LinqExtensions { | ||
public static partial class LinqExtensions { | ||
public static T[] Slice<T>(this T[] source, int index, int length) { | ||
var slice = new T[length]; | ||
Array.Copy(source, index, slice, 0, length); | ||
return slice; | ||
} | ||
public static T[] Slice<T>(this T[] source, int length) | ||
=> source.Slice(0, length); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 10 additions & 5 deletions
15
src/Extensions/Xpand.Extensions/ObjectExtensions/IsDefaultValue.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,18 @@ | ||
using Xpand.Extensions.TypeExtensions; | ||
using System; | ||
using Xpand.Extensions.TypeExtensions; | ||
|
||
namespace Xpand.Extensions.ObjectExtensions{ | ||
public static partial class ObjectExtensions{ | ||
public static bool IsDefaultValue<TSource>(this TSource source){ | ||
var def = default(TSource); | ||
return def != null ? def.Equals(source) : source == null; | ||
} | ||
public static bool IsDefaultValue<TSource>(this TSource source) { | ||
var def = default(TSource); | ||
return def != null ? def.Equals(source) : typeof(TSource) == typeof(object) | ||
? source == null || source.Equals(source.GetType().DefaultValue()) : source == null; | ||
} | ||
|
||
public static bool IsDefaultValue(this object source) | ||
=> source == null || source.Equals(source.GetType().DefaultValue()); | ||
|
||
public static bool IsDefaultValue(this object source,Type objectType) | ||
=> objectType.DefaultValue()==source; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters