Skip to content

Commit db8844e

Browse files
author
Samuel Abraham
committed
v9.1.2
1 parent 9cd4497 commit db8844e

8 files changed

Lines changed: 36 additions & 9 deletions

File tree

src/TypeCache.GraphQL/TypeCache.GraphQL.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<Nullable>enable</Nullable>
55
<RootNamespace>TypeCache.GraphQL</RootNamespace>
66
<PackageId>TypeCache.GraphQL</PackageId>
7-
<Version>9.1.1</Version>
7+
<Version>9.1.2</Version>
88
<Authors>Samuel Abraham &lt;sam987883@gmail.com&gt;</Authors>
99
<Company>Samuel Abraham &lt;sam987883@gmail.com&gt;</Company>
1010
<Title>TypeCache GraphQL</Title>

src/TypeCache.GraphQL/Types/HashIdGraphType.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@
99
namespace TypeCache.GraphQL.Types;
1010

1111
/// <summary>
12-
/// Requires call to either one of:
12+
/// Requires call to any one of:
1313
/// <list type="bullet">
14+
/// <item><see cref="TypeCache.Extensions.ServiceCollectionExtensions.AddHashMaker(IServiceCollection, byte[])"/></item>
1415
/// <item><see cref="TypeCache.Extensions.ServiceCollectionExtensions.AddHashMaker(IServiceCollection, byte[], byte[])"/></item>
15-
/// <item><see cref="TypeCache.Extensions.ServiceCollectionExtensions.AddHashMaker(IServiceCollection, decimal, decimal)"/></item>
16+
/// <item><see cref="TypeCache.Extensions.ServiceCollectionExtensions.AddHashMaker(IServiceCollection, ReadOnlySpan{char})"/></item>
17+
/// <item><see cref="TypeCache.Extensions.ServiceCollectionExtensions.AddHashMaker(IServiceCollection, ReadOnlySpan{char}, ReadOnlySpan{char})"/></item>
1618
/// </list>
1719
/// </summary>
1820
public sealed class HashIdGraphType : ScalarGraphType

src/TypeCache/Attributes/ScopedAttribute.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44

55
namespace TypeCache.Attributes;
66

7+
/// <inheritdoc cref="ServiceLifetime.Scoped"/>
8+
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Enum | AttributeTargets.Struct, AllowMultiple = false, Inherited = false)]
9+
public sealed class ScopedAttribute(object? key = null) : ServiceLifetimeAttribute(ServiceLifetime.Scoped, null, key)
10+
{
11+
}
12+
713
/// <inheritdoc cref="ServiceLifetime.Scoped"/>
814
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Enum | AttributeTargets.Struct, AllowMultiple = false, Inherited = false)]
915
public sealed class ScopedAttribute<T>(object? key = null) : ServiceLifetimeAttribute(ServiceLifetime.Scoped, typeof(T), key)

src/TypeCache/Attributes/SingletonAttribute.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44

55
namespace TypeCache.Attributes;
66

7+
/// <inheritdoc cref="ServiceLifetime.Singleton"/>
8+
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Enum | AttributeTargets.Struct, AllowMultiple = false, Inherited = false)]
9+
public sealed class SingletonAttribute(object? key = null) : ServiceLifetimeAttribute(ServiceLifetime.Singleton, null, key)
10+
{
11+
}
12+
713
/// <inheritdoc cref="ServiceLifetime.Singleton"/>
814
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Enum | AttributeTargets.Struct, AllowMultiple = false, Inherited = false)]
915
public sealed class SingletonAttribute<T>(object? key = null) : ServiceLifetimeAttribute(ServiceLifetime.Singleton, typeof(T), key)

src/TypeCache/Attributes/TransientAttribute.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44

55
namespace TypeCache.Attributes;
66

7+
/// <inheritdoc cref="ServiceLifetime.Transient"/>
8+
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Enum | AttributeTargets.Struct, AllowMultiple = false, Inherited = false)]
9+
public sealed class TransientAttribute(object? key = null) : ServiceLifetimeAttribute(ServiceLifetime.Transient, null, key)
10+
{
11+
}
12+
713
/// <inheritdoc cref="ServiceLifetime.Transient"/>
814
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Enum | AttributeTargets.Struct, AllowMultiple = false, Inherited = false)]
915
public sealed class TransientAttribute<T>(object? key = null) : ServiceLifetimeAttribute(ServiceLifetime.Transient, typeof(T), key)

src/TypeCache/Extensions/ServiceCollectionExtensions.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -455,15 +455,19 @@ public static IServiceCollection AddServiceDescriptor<T>(this IServiceCollection
455455
/// </summary>
456456
public static IServiceCollection AddSqlCommandRules(this IServiceCollection @this)
457457
=> @this.AddRule<SqlDataSetRequest, DataSet>(new SqlDataSetRule())
458-
.AddRule<SqlDataSetRequest, DataSet>(new SqlDataSetRule())
459458
.AddRule<SqlDataTableRequest, DataTable>(new SqlDataTableRule())
460459
.AddRule<SqlExecuteRequest>(new SqlExecuteRule())
461460
.AddRule<SqlResultJsonRequest, JsonArray>(new SqlResultJsonRule())
462461
.AddRule<SqlModelsRequest, IList<object>>(new SqlResultsRule())
463462
.AddRule<SqlScalarRequest, object?>(new SqlScalarRule());
464463

465464
/// <summary>
466-
/// Registers all types in the specified assembly that have <see cref="ServiceLifetimeAttribute{T}"/> or <see cref="ServiceLifetimeAttribute"/>.
465+
/// Registers all types in the specified assembly that have one of:
466+
/// <list type="bullet">
467+
/// <item><c><see cref="SingletonAttribute"/></c> or <c><see cref="SingletonAttribute{T}"/></c></item>
468+
/// <item><c><see cref="ScopedAttribute"/></c> or <c><see cref="ScopedAttribute{T}"/></c></item>
469+
/// <item><c><see cref="TransientAttribute"/></c> or <c><see cref="TransientAttribute{T}"/></c></item>
470+
/// </list>
467471
/// </summary>
468472
/// <param name="fromAssembly">The assembly to register the types from.</param>
469473
public static IServiceCollection AddTypes(this IServiceCollection @this, Assembly fromAssembly)
@@ -537,7 +541,10 @@ public static IServiceCollection AddValidationRule<REQUEST>(this IServiceCollect
537541

538542
private static ServiceDescriptor ToServiceDescriptor(this Type @this)
539543
{
540-
var attribute = @this.GetCustomAttribute<ServiceLifetimeAttribute>()!;
544+
var attributes = @this.GetCustomAttributes<ServiceLifetimeAttribute>();
545+
attributes.Count().ThrowIfNotEqual(1);
546+
547+
var attribute = attributes.First();
541548
return attribute.Key is not null
542549
? ServiceDescriptor.DescribeKeyed(attribute.ServiceType ?? @this, attribute.Key, @this, attribute.ServiceLifetime)
543550
: ServiceDescriptor.Describe(attribute.ServiceType ?? @this, @this, attribute.ServiceLifetime);

src/TypeCache/Extensions/StringExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ public static string ToBase64Url(this string @this, Encoding? encoding = null)
453453

454454
/// <inheritdoc cref="Enum.TryParse{TEnum}(string?, out TEnum)"/>
455455
/// <remarks>
456-
/// <c>=&gt; <see cref="Enum"/>.TryParse(@<paramref name="this"/>, <see langword="out"/> <typeparamref name="T"/> result) ? (<typeparamref name="T"/>?)result : <see langword="null"/>;</c>
456+
/// <c>=&gt; <see cref="Enum"/>.TryParse(@<paramref name="this"/>, <see langword="out"/> <see langword="var"/> result) ? (<typeparamref name="T"/>?)result : <see langword="null"/>;</c>
457457
/// </remarks>
458458
[DebuggerHidden]
459459
public static T? ToEnum<T>(this string? @this)
@@ -462,7 +462,7 @@ public static string ToBase64Url(this string @this, Encoding? encoding = null)
462462

463463
/// <inheritdoc cref="Enum.TryParse{TEnum}(string?, bool, out TEnum)"/>
464464
/// <remarks>
465-
/// <c>=&gt; <see cref="Enum"/>.TryParse(@<paramref name="this"/>, <paramref name="ignoreCase"/>, <see langword="out"/> <typeparamref name="T"/> result) ? (<typeparamref name="T"/>?)result : <see langword="null"/>;</c>
465+
/// <c>=&gt; <see cref="Enum"/>.TryParse(@<paramref name="this"/>, <see langword="true"/>, <see langword="out"/> <see langword="var"/> result) ? (<typeparamref name="T"/>?)result : <see langword="null"/>;</c>
466466
/// </remarks>
467467
[DebuggerHidden]
468468
public static T? ToEnumIgnoreCase<T>(this string? @this)

src/TypeCache/TypeCache.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<RootNamespace>TypeCache</RootNamespace>
77
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
88
<PackageId>TypeCache</PackageId>
9-
<Version>9.1.1</Version>
9+
<Version>9.1.2</Version>
1010
<Authors>Samuel Abraham &lt;sam987883@gmail.com&gt;</Authors>
1111
<Company>Samuel Abraham &lt;sam987883@gmail.com&gt;</Company>
1212
<Title>TypeCache Reflection</Title>

0 commit comments

Comments
 (0)