Skip to content

Instantly share code, notes, and snippets.

@Alxandr
Created June 11, 2024 11:17
Show Gist options
  • Save Alxandr/2214ea6cffeeb300ce73b91996cea5b6 to your computer and use it in GitHub Desktop.
Save Alxandr/2214ea6cffeeb300ce73b91996cea5b6 to your computer and use it in GitHub Desktop.
/// <summary>
/// Creates a new <see cref="ValidationErrorInstance"/> with the specified <paramref name="descriptor"/>.
/// </summary>
/// <param name="descriptor">The <see cref="ValidationErrorDescriptor"/>.</param>
/// <returns>A <see cref="ValidationErrorInstance"/>.</returns>
public static ValidationErrorInstance Create(ValidationErrorDescriptor descriptor) =>
new ValidationErrorInstance(descriptor, paths: [], extensions: []);
/// <summary>
/// Creates a new <see cref="ValidationErrorInstance"/> with the specified <paramref name="descriptor"/> and <paramref name="path"/>.
/// </summary>
/// <param name="descriptor">The <see cref="ValidationErrorDescriptor"/>.</param>
/// <param name="path">The path.</param>
/// <returns>A <see cref="ValidationErrorInstance"/>.</returns>
public static ValidationErrorInstance Create(ValidationErrorDescriptor descriptor, string path) =>
new ValidationErrorInstance(descriptor, paths: [path], extensions: []);
/// <summary>
/// Creates a new <see cref="ValidationErrorInstance"/> with the specified <paramref name="descriptor"/> and <paramref name="paths"/>.
/// </summary>
/// <param name="descriptor">The <see cref="ValidationErrorDescriptor"/>.</param>
/// <param name="paths">The paths.</param>
/// <returns>A <see cref="ValidationErrorInstance"/>.</returns>
public static ValidationErrorInstance Create(ValidationErrorDescriptor descriptor, ImmutableArray<string> paths) =>
new ValidationErrorInstance(descriptor, paths: paths, extensions: []);
/// <summary>
/// Creates a new <see cref="ValidationErrorInstance"/> with the specified <paramref name="descriptor"/> and <paramref name="paths"/>.
/// </summary>
/// <param name="descriptor">The <see cref="ValidationErrorDescriptor"/>.</param>
/// <param name="paths">The paths.</param>
/// <returns>A <see cref="ValidationErrorInstance"/>.</returns>
public static ValidationErrorInstance Create(ValidationErrorDescriptor descriptor, ReadOnlySpan<string> paths) =>
new ValidationErrorInstance(descriptor, paths: [.. paths], extensions: []);
/// <summary>
/// Creates a new <see cref="ValidationErrorInstance"/> with the specified <paramref name="descriptor"/> and <paramref name="paths"/>.
/// </summary>
/// <param name="descriptor">The <see cref="ValidationErrorDescriptor"/>.</param>
/// <param name="paths">The paths.</param>
/// <returns>A <see cref="ValidationErrorInstance"/>.</returns>
public static ValidationErrorInstance Create(ValidationErrorDescriptor descriptor, IEnumerable<string> paths) =>
new ValidationErrorInstance(descriptor, paths: [.. paths], extensions: []);
/// <summary>
/// Creates a new <see cref="ValidationErrorInstance"/> with the specified <paramref name="descriptor"/> and <paramref name="extensions"/>.
/// </summary>
/// <param name="descriptor">The <see cref="ValidationErrorDescriptor"/>.</param>
/// <param name="extensions">The extensions.</param>
/// <returns>A <see cref="ValidationErrorInstance"/>.</returns>
public static ValidationErrorInstance Create(ValidationErrorDescriptor descriptor, ImmutableArray<KeyValuePair<string, string>> extensions) =>
new ValidationErrorInstance(descriptor, paths: [], extensions: extensions);
/// <summary>
/// Creates a new <see cref="ValidationErrorInstance"/> with the specified <paramref name="descriptor"/> and <paramref name="extensions"/>.
/// </summary>
/// <param name="descriptor">The <see cref="ValidationErrorDescriptor"/>.</param>
/// <param name="extensions">The extensions.</param>
/// <returns>A <see cref="ValidationErrorInstance"/>.</returns>
public static ValidationErrorInstance Create(ValidationErrorDescriptor descriptor, ReadOnlySpan<KeyValuePair<string, string>> extensions) =>
new ValidationErrorInstance(descriptor, paths: [], extensions: [.. extensions]);
/// <summary>
/// Creates a new <see cref="ValidationErrorInstance"/> with the specified <paramref name="descriptor"/> and <paramref name="extensions"/>.
/// </summary>
/// <param name="descriptor">The <see cref="ValidationErrorDescriptor"/>.</param>
/// <param name="extensions">The extensions.</param>
/// <returns>A <see cref="ValidationErrorInstance"/>.</returns>
public static ValidationErrorInstance Create(ValidationErrorDescriptor descriptor, IReadOnlyDictionary<string, string> extensions) =>
new ValidationErrorInstance(descriptor, paths: [], extensions: [.. extensions]);
/// <summary>
/// Creates a new <see cref="ValidationErrorInstance"/> with the specified <paramref name="descriptor"/>, <paramref name="path"/>, and <paramref name="extensions"/>.
/// </summary>
/// <param name="descriptor">The <see cref="ValidationErrorDescriptor"/>.</param>
/// <param name="path">The path.</param>
/// <param name="extensions">The extensions.</param>
/// <returns>A <see cref="ValidationErrorInstance"/>.</returns>
public static ValidationErrorInstance Create(ValidationErrorDescriptor descriptor, string path, ImmutableArray<KeyValuePair<string, string>> extensions) =>
new ValidationErrorInstance(descriptor, paths: [path], extensions: extensions);
/// <summary>
/// Creates a new <see cref="ValidationErrorInstance"/> with the specified <paramref name="descriptor"/>, <paramref name="path"/>, and <paramref name="extensions"/>.
/// </summary>
/// <param name="descriptor">The <see cref="ValidationErrorDescriptor"/>.</param>
/// <param name="path">The path.</param>
/// <param name="extensions">The extensions.</param>
/// <returns>A <see cref="ValidationErrorInstance"/>.</returns>
public static ValidationErrorInstance Create(ValidationErrorDescriptor descriptor, string path, ReadOnlySpan<KeyValuePair<string, string>> extensions) =>
new ValidationErrorInstance(descriptor, paths: [path], extensions: [.. extensions]);
/// <summary>
/// Creates a new <see cref="ValidationErrorInstance"/> with the specified <paramref name="descriptor"/>, <paramref name="path"/>, and <paramref name="extensions"/>.
/// </summary>
/// <param name="descriptor">The <see cref="ValidationErrorDescriptor"/>.</param>
/// <param name="path">The path.</param>
/// <param name="extensions">The extensions.</param>
/// <returns>A <see cref="ValidationErrorInstance"/>.</returns>
public static ValidationErrorInstance Create(ValidationErrorDescriptor descriptor, string path, IReadOnlyDictionary<string, string> extensions) =>
new ValidationErrorInstance(descriptor, paths: [path], extensions: [.. extensions]);
/// <summary>
/// Creates a new <see cref="ValidationErrorInstance"/> with the specified <paramref name="descriptor"/>, <paramref name="paths"/>, and <paramref name="extensions"/>.
/// </summary>
/// <param name="descriptor">The <see cref="ValidationErrorDescriptor"/>.</param>
/// <param name="paths">The paths.</param>
/// <param name="extensions">The extensions.</param>
/// <returns>A <see cref="ValidationErrorInstance"/>.</returns>
public static ValidationErrorInstance Create(ValidationErrorDescriptor descriptor, ImmutableArray<string> paths, ImmutableArray<KeyValuePair<string, string>> extensions) =>
new ValidationErrorInstance(descriptor, paths: paths, extensions: extensions);
/// <summary>
/// Creates a new <see cref="ValidationErrorInstance"/> with the specified <paramref name="descriptor"/>, <paramref name="paths"/>, and <paramref name="extensions"/>.
/// </summary>
/// <param name="descriptor">The <see cref="ValidationErrorDescriptor"/>.</param>
/// <param name="paths">The paths.</param>
/// <param name="extensions">The extensions.</param>
/// <returns>A <see cref="ValidationErrorInstance"/>.</returns>
public static ValidationErrorInstance Create(ValidationErrorDescriptor descriptor, ImmutableArray<string> paths, ReadOnlySpan<KeyValuePair<string, string>> extensions) =>
new ValidationErrorInstance(descriptor, paths: paths, extensions: [.. extensions]);
/// <summary>
/// Creates a new <see cref="ValidationErrorInstance"/> with the specified <paramref name="descriptor"/>, <paramref name="paths"/>, and <paramref name="extensions"/>.
/// </summary>
/// <param name="descriptor">The <see cref="ValidationErrorDescriptor"/>.</param>
/// <param name="paths">The paths.</param>
/// <param name="extensions">The extensions.</param>
/// <returns>A <see cref="ValidationErrorInstance"/>.</returns>
public static ValidationErrorInstance Create(ValidationErrorDescriptor descriptor, ImmutableArray<string> paths, IReadOnlyDictionary<string, string> extensions) =>
new ValidationErrorInstance(descriptor, paths: paths, extensions: [.. extensions]);
/// <summary>
/// Creates a new <see cref="ValidationErrorInstance"/> with the specified <paramref name="descriptor"/>, <paramref name="paths"/>, and <paramref name="extensions"/>.
/// </summary>
/// <param name="descriptor">The <see cref="ValidationErrorDescriptor"/>.</param>
/// <param name="paths">The paths.</param>
/// <param name="extensions">The extensions.</param>
/// <returns>A <see cref="ValidationErrorInstance"/>.</returns>
public static ValidationErrorInstance Create(ValidationErrorDescriptor descriptor, ReadOnlySpan<string> paths, ImmutableArray<KeyValuePair<string, string>> extensions) =>
new ValidationErrorInstance(descriptor, paths: [.. paths], extensions: extensions);
/// <summary>
/// Creates a new <see cref="ValidationErrorInstance"/> with the specified <paramref name="descriptor"/>, <paramref name="paths"/>, and <paramref name="extensions"/>.
/// </summary>
/// <param name="descriptor">The <see cref="ValidationErrorDescriptor"/>.</param>
/// <param name="paths">The paths.</param>
/// <param name="extensions">The extensions.</param>
/// <returns>A <see cref="ValidationErrorInstance"/>.</returns>
public static ValidationErrorInstance Create(ValidationErrorDescriptor descriptor, ReadOnlySpan<string> paths, ReadOnlySpan<KeyValuePair<string, string>> extensions) =>
new ValidationErrorInstance(descriptor, paths: [.. paths], extensions: [.. extensions]);
/// <summary>
/// Creates a new <see cref="ValidationErrorInstance"/> with the specified <paramref name="descriptor"/>, <paramref name="paths"/>, and <paramref name="extensions"/>.
/// </summary>
/// <param name="descriptor">The <see cref="ValidationErrorDescriptor"/>.</param>
/// <param name="paths">The paths.</param>
/// <param name="extensions">The extensions.</param>
/// <returns>A <see cref="ValidationErrorInstance"/>.</returns>
public static ValidationErrorInstance Create(ValidationErrorDescriptor descriptor, ReadOnlySpan<string> paths, IReadOnlyDictionary<string, string> extensions) =>
new ValidationErrorInstance(descriptor, paths: [.. paths], extensions: [.. extensions]);
/// <summary>
/// Creates a new <see cref="ValidationErrorInstance"/> with the specified <paramref name="descriptor"/>, <paramref name="paths"/>, and <paramref name="extensions"/>.
/// </summary>
/// <param name="descriptor">The <see cref="ValidationErrorDescriptor"/>.</param>
/// <param name="paths">The paths.</param>
/// <param name="extensions">The extensions.</param>
/// <returns>A <see cref="ValidationErrorInstance"/>.</returns>
public static ValidationErrorInstance Create(ValidationErrorDescriptor descriptor, IEnumerable<string> paths, ImmutableArray<KeyValuePair<string, string>> extensions) =>
new ValidationErrorInstance(descriptor, paths: [.. paths], extensions: extensions);
/// <summary>
/// Creates a new <see cref="ValidationErrorInstance"/> with the specified <paramref name="descriptor"/>, <paramref name="paths"/>, and <paramref name="extensions"/>.
/// </summary>
/// <param name="descriptor">The <see cref="ValidationErrorDescriptor"/>.</param>
/// <param name="paths">The paths.</param>
/// <param name="extensions">The extensions.</param>
/// <returns>A <see cref="ValidationErrorInstance"/>.</returns>
public static ValidationErrorInstance Create(ValidationErrorDescriptor descriptor, IEnumerable<string> paths, ReadOnlySpan<KeyValuePair<string, string>> extensions) =>
new ValidationErrorInstance(descriptor, paths: [.. paths], extensions: [.. extensions]);
/// <summary>
/// Creates a new <see cref="ValidationErrorInstance"/> with the specified <paramref name="descriptor"/>, <paramref name="paths"/>, and <paramref name="extensions"/>.
/// </summary>
/// <param name="descriptor">The <see cref="ValidationErrorDescriptor"/>.</param>
/// <param name="paths">The paths.</param>
/// <param name="extensions">The extensions.</param>
/// <returns>A <see cref="ValidationErrorInstance"/>.</returns>
public static ValidationErrorInstance Create(ValidationErrorDescriptor descriptor, IEnumerable<string> paths, IReadOnlyDictionary<string, string> extensions) =>
new ValidationErrorInstance(descriptor, paths: [.. paths], extensions: [.. extensions]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment