Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# (Temporary?) Fork of [Schema.NET](https://github.com/RehanSaeed/Schema.NET)
### Changes:
- Add targets for .NET 8 - 10
- Add support for [collection expressions](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/operators/collection-expressions)
- Removed targets for EOL .NET versions and .Net Framework
- Add support for [collection expressions](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/operators/collection-expressions) [#36](https://github.com/TimmyMC/Schema.NET/pull/36)
- Added debugging attributes [#48](https://github.com/TimmyMC/Schema.NET/pull/48)
- Performance improvements
### Why the fork?
> I created this fork for to use in a large webshop, I initially wanted the package to target .net 8.<br/>
Expand Down
1 change: 1 addition & 0 deletions Schema.NET.sln
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Common", "Common", "{AF228B
Source\Common\Values{T1,T2,T3,T4}.cs = Source\Common\Values{T1,T2,T3,T4}.cs
Source\Common\Values{T1,T2,T3}.cs = Source\Common\Values{T1,T2,T3}.cs
Source\Common\Values{T1,T2}.cs = Source\Common\Values{T1,T2}.cs
Source\Common\IValuesDebugView.cs = Source\Common\IValuesDebugView.cs
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Schema.NET.Updater", "Tools\Schema.NET.Updater\Schema.NET.Updater.csproj", "{8923F9E2-4BB8-45F9-9A85-863F381B46EE}"
Expand Down
22 changes: 22 additions & 0 deletions Source/Common/IValuesDebugView.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
namespace Schema.NET;

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

internal sealed class IValuesDebugView
{
private readonly IEnumerable<object> collection;

public IValuesDebugView(IEnumerable<object> collection)
{
ArgumentNullException.ThrowIfNull(collection);

this.collection = collection;
}

[DebuggerBrowsable(DebuggerBrowsableState.RootHidden)]
public object[] Items => this.collection.ToArray();
}

12 changes: 12 additions & 0 deletions Source/Common/OneOrMany{T}.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ namespace Schema.NET;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Runtime.CompilerServices;
Expand All @@ -12,11 +13,13 @@ namespace Schema.NET;
/// </summary>
/// <typeparam name="T">The type of the values.</typeparam>
/// <seealso cref="IReadOnlyCollection{T}" />
[DebuggerDisplay("{DebuggerDisplay,nq}")]
[CollectionBuilder(typeof(OneOrManyBuilder), nameof(OneOrManyBuilder.Create))]
#pragma warning disable CA1710 // Identifiers should have correct suffix.
public readonly struct OneOrMany<T> : IReadOnlyCollection<T>, IValues, IEquatable<OneOrMany<T>>
#pragma warning restore CA1710 // Identifiers should have correct suffix.
{
[DebuggerBrowsable(DebuggerBrowsableState.RootHidden)]
private readonly T[]? collection;

/// <summary>
Expand Down Expand Up @@ -107,18 +110,21 @@ public OneOrMany(IEnumerable<object?> collection) : this(collection.Cast<T?>().T
/// <summary>
/// Gets the number of elements contained in the <see cref="OneOrMany{T}"/>.
/// </summary>
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
public int Count => this.collection?.Length ?? 0;

/// <summary>
/// Gets a value indicating whether this instance has a single item value.
/// </summary>
/// <value><c>true</c> if this instance has a single item value; otherwise, <c>false</c>.</value>
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
public bool HasOne { get; }

/// <summary>
/// Gets a value indicating whether this instance has more than one value.
/// </summary>
/// <value><c>true</c> if this instance has more than one value; otherwise, <c>false</c>.</value>
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
public bool HasMany => this.collection?.Length > 1;

/// <summary>
Expand Down Expand Up @@ -286,6 +292,12 @@ public bool Equals(OneOrMany<T> other)
/// </summary>
/// <returns>A <see cref="ReadOnlySpan{T}"/> wrapping the current items.</returns>
public ReadOnlySpan<T> AsSpan() => this.collection.AsSpan();

/// <summary>
/// Gets the string to display in the debugger watches window for this instance.
/// </summary>
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
private string DebuggerDisplay => $"Length = {this.Count}";
}

/// <summary>
Expand Down
9 changes: 9 additions & 0 deletions Source/Common/Values{T1,T2,T3,T4,T5,T6,T7}.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ namespace Schema.NET;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.CompilerServices;

Expand All @@ -16,6 +17,8 @@ namespace Schema.NET;
/// <typeparam name="T5">The fifth type the values can take.</typeparam>
/// <typeparam name="T6">The sixth type the values can take.</typeparam>
/// <typeparam name="T7">The seventh type the values can take.</typeparam>
[DebuggerDisplay("{DebuggerDisplay,nq}")]
[DebuggerTypeProxy(typeof(IValuesDebugView))]
[CollectionBuilder(typeof(ValuesBuilder), nameof(ValuesBuilder.Create))]
public readonly struct Values<T1, T2, T3, T4, T5, T6, T7> : IReadOnlyCollection<object?>, IValues, IEquatable<Values<T1, T2, T3, T4, T5, T6, T7>>
{
Expand Down Expand Up @@ -895,6 +898,12 @@ public bool Equals(Values<T1, T2, T3, T4, T5, T6, T7> other)
/// </returns>
public override int GetHashCode() =>
HashCode.Of(this.Value1).And(this.Value2).And(this.Value3).And(this.Value4).And(this.Value5).And(this.Value6).And(this.Value7);

/// <summary>
/// Gets the string to display in the debugger watches window for this instance.
/// </summary>
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
private string DebuggerDisplay => $"Length = {this.Count}";
}

public static partial class ValuesBuilder
Expand Down
9 changes: 9 additions & 0 deletions Source/Common/Values{T1,T2,T3,T4,T5,T6}.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ namespace Schema.NET;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.CompilerServices;

Expand All @@ -15,6 +16,8 @@ namespace Schema.NET;
/// <typeparam name="T4">The fourth type the values can take.</typeparam>
/// <typeparam name="T5">The fifth type the values can take.</typeparam>
/// <typeparam name="T6">The sixth type the values can take.</typeparam>
[DebuggerDisplay("{DebuggerDisplay,nq}")]
[DebuggerTypeProxy(typeof(IValuesDebugView))]
[CollectionBuilder(typeof(ValuesBuilder), nameof(ValuesBuilder.Create))]
public readonly struct Values<T1, T2, T3, T4, T5, T6> : IReadOnlyCollection<object?>, IValues, IEquatable<Values<T1, T2, T3, T4, T5, T6>>
{
Expand Down Expand Up @@ -775,6 +778,12 @@ public bool Equals(Values<T1, T2, T3, T4, T5, T6> other)
/// </returns>
public override int GetHashCode() =>
HashCode.Of(this.Value1).And(this.Value2).And(this.Value3).And(this.Value4).And(this.Value5).And(this.Value6);

/// <summary>
/// Gets the string to display in the debugger watches window for this instance.
/// </summary>
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
private string DebuggerDisplay => $"Length = {this.Count}";
}

public static partial class ValuesBuilder
Expand Down
9 changes: 9 additions & 0 deletions Source/Common/Values{T1,T2,T3,T4,T5}.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ namespace Schema.NET;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.CompilerServices;

Expand All @@ -14,6 +15,8 @@ namespace Schema.NET;
/// <typeparam name="T3">The third type the values can take.</typeparam>
/// <typeparam name="T4">The fourth type the values can take.</typeparam>
/// <typeparam name="T5">The fifth type the values can take.</typeparam>
[DebuggerDisplay("{DebuggerDisplay,nq}")]
[DebuggerTypeProxy(typeof(IValuesDebugView))]
[CollectionBuilder(typeof(ValuesBuilder), nameof(ValuesBuilder.Create))]
public readonly struct Values<T1, T2, T3, T4, T5> : IReadOnlyCollection<object?>, IValues, IEquatable<Values<T1, T2, T3, T4, T5>>
{
Expand Down Expand Up @@ -659,6 +662,12 @@ public bool Equals(Values<T1, T2, T3, T4, T5> other)
/// </returns>
public override int GetHashCode() =>
HashCode.Of(this.Value1).And(this.Value2).And(this.Value3).And(this.Value4).And(this.Value5);

/// <summary>
/// Gets the string to display in the debugger watches window for this instance.
/// </summary>
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
private string DebuggerDisplay => $"Length = {this.Count}";
}

public static partial class ValuesBuilder
Expand Down
9 changes: 9 additions & 0 deletions Source/Common/Values{T1,T2,T3,T4}.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ namespace Schema.NET;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.CompilerServices;

Expand All @@ -13,6 +14,8 @@ namespace Schema.NET;
/// <typeparam name="T2">The second type the values can take.</typeparam>
/// <typeparam name="T3">The third type the values can take.</typeparam>
/// <typeparam name="T4">The fourth type the values can take.</typeparam>
[DebuggerDisplay("{DebuggerDisplay,nq}")]
[DebuggerTypeProxy(typeof(IValuesDebugView))]
[CollectionBuilder(typeof(ValuesBuilder), nameof(ValuesBuilder.Create))]
public readonly struct Values<T1, T2, T3, T4> : IReadOnlyCollection<object?>, IValues, IEquatable<Values<T1, T2, T3, T4>>
{
Expand Down Expand Up @@ -547,6 +550,12 @@ public bool Equals(Values<T1, T2, T3, T4> other)
/// </returns>
public override int GetHashCode() =>
HashCode.Of(this.Value1).And(this.Value2).And(this.Value3).And(this.Value4);

/// <summary>
/// Gets the string to display in the debugger watches window for this instance.
/// </summary>
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
private string DebuggerDisplay => $"Length = {this.Count}";
}

public static partial class ValuesBuilder
Expand Down
9 changes: 9 additions & 0 deletions Source/Common/Values{T1,T2,T3}.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ namespace Schema.NET;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.CompilerServices;

Expand All @@ -12,6 +13,8 @@ namespace Schema.NET;
/// <typeparam name="T1">The first type the values can take.</typeparam>
/// <typeparam name="T2">The second type the values can take.</typeparam>
/// <typeparam name="T3">The third type the values can take.</typeparam>
[DebuggerDisplay("{DebuggerDisplay,nq}")]
[DebuggerTypeProxy(typeof(IValuesDebugView))]
[CollectionBuilder(typeof(ValuesBuilder), nameof(ValuesBuilder.Create))]
public readonly struct Values<T1, T2, T3> : IReadOnlyCollection<object?>, IValues, IEquatable<Values<T1, T2, T3>>
{
Expand Down Expand Up @@ -438,6 +441,12 @@ public bool Equals(Values<T1, T2, T3> other)
/// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
/// </returns>
public override int GetHashCode() => HashCode.Of(this.Value1).And(this.Value2).And(this.Value3);

/// <summary>
/// Gets the string to display in the debugger watches window for this instance.
/// </summary>
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
private string DebuggerDisplay => $"Length = {this.Count}";
}

public static partial class ValuesBuilder
Expand Down
9 changes: 9 additions & 0 deletions Source/Common/Values{T1,T2}.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ namespace Schema.NET;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.CompilerServices;

Expand All @@ -11,6 +12,8 @@ namespace Schema.NET;
/// </summary>
/// <typeparam name="T1">The first type the values can take.</typeparam>
/// <typeparam name="T2">The second type the values can take.</typeparam>
[DebuggerDisplay("{DebuggerDisplay,nq}")]
[DebuggerTypeProxy(typeof(IValuesDebugView))]
[CollectionBuilder(typeof(ValuesBuilder), nameof(ValuesBuilder.Create))]
public readonly struct Values<T1, T2> : IReadOnlyCollection<object?>, IValues, IEquatable<Values<T1, T2>>
{
Expand Down Expand Up @@ -334,6 +337,12 @@ public bool Equals(Values<T1, T2> other)
/// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
/// </returns>
public override int GetHashCode() => HashCode.Of(this.Value1).And(this.Value2);

/// <summary>
/// Gets the string to display in the debugger watches window for this instance.
/// </summary>
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
private string DebuggerDisplay => $"Length = {this.Count}";
}

/// <summary>
Expand Down
Loading