Skip to content

Commit

Permalink
v8.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuel Abraham committed Jan 31, 2024
1 parent 55c1ea0 commit b125773
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 40 deletions.
37 changes: 19 additions & 18 deletions src/TypeCache.Web/Extensions/EndpointRouteBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using Microsoft.Extensions.Primitives;
using TypeCache.Converters;
using TypeCache.Extensions;
using TypeCache.Mediation;
using TypeCache.Web.Filters;
using TypeCache.Web.Handlers;
using static System.FormattableString;
Expand Down Expand Up @@ -230,7 +231,7 @@ public static RouteGroupBuilder MapSqlApi(this IEndpointRouteBuilder @this, stri
/// <c>GET|POST /{{dataSource:string}}/procedure/{{database:string}}/{{schema:string}}/{{procedure:string}}</c><br/><br/>
/// <i><b>Requires calls to:</b></i>
/// <code>
/// <see cref="TypeCache.Extensions.ServiceCollectionExtensions.AddSqlCommandRules(IServiceCollection)"/><br/>
/// <see cref="TypeCache.Extensions.RulesBuilderExtensions.AddSqlCommandRules(RulesBuilder)"/><br/>
/// <see cref="ServiceCollectionExtensions.ConfigureSqlApi(IServiceCollection)"/><br/>
/// </code>
/// </summary>
Expand All @@ -243,7 +244,7 @@ public static RouteHandlerBuilder MapSqlApiCallProcedure(this IEndpointRouteBuil
/// <c>DELETE /{{dataSource:string}}/table/{{database:string}}/{{schema:string}}/{{table:string}}</c><br/><br/>
/// <i><b>Requires calls to:</b></i>
/// <code>
/// <see cref="TypeCache.Extensions.ServiceCollectionExtensions.AddSqlCommandRules(IServiceCollection)"/><br/>
/// <see cref="TypeCache.Extensions.RulesBuilderExtensions.AddSqlCommandRules(RulesBuilder)"/><br/>
/// <see cref="ServiceCollectionExtensions.ConfigureSqlApi(IServiceCollection)"/><br/>
/// </code>
/// </summary>
Expand All @@ -257,7 +258,7 @@ public static RouteHandlerBuilder MapSqlApiDelete(this IEndpointRouteBuilder @th
/// Body is an array of data whose property names match the primary keys of the table to delete from.<br/><br/>
/// <i><b>Requires calls to:</b></i>
/// <code>
/// <see cref="TypeCache.Extensions.ServiceCollectionExtensions.AddSqlCommandRules(IServiceCollection)"/><br/>
/// <see cref="TypeCache.Extensions.RulesBuilderExtensions.AddSqlCommandRules(RulesBuilder)"/><br/>
/// <see cref="ServiceCollectionExtensions.ConfigureSqlApi(IServiceCollection)"/><br/>
/// </code>
/// </summary>
Expand All @@ -271,7 +272,7 @@ public static RouteHandlerBuilder MapSqlApiDeleteBatch(this IEndpointRouteBuilde
/// Returns generated SQL statement.<br/><br/>
/// <i><b>Requires calls to:</b></i>
/// <code>
/// <see cref="TypeCache.Extensions.ServiceCollectionExtensions.AddSqlCommandRules(IServiceCollection)"/><br/>
/// <see cref="TypeCache.Extensions.RulesBuilderExtensions.AddSqlCommandRules(RulesBuilder)"/><br/>
/// <see cref="ServiceCollectionExtensions.ConfigureSqlApi(IServiceCollection)"/><br/>
/// </code>
/// </summary>
Expand All @@ -286,7 +287,7 @@ public static RouteHandlerBuilder MapSqlApiGetDeleteSQL(this IEndpointRouteBuild
/// Returns generated SQL statement.<br/><br/>
/// <i><b>Requires calls to:</b></i>
/// <code>
/// <see cref="TypeCache.Extensions.ServiceCollectionExtensions.AddSqlCommandRules(IServiceCollection)"/><br/>
/// <see cref="TypeCache.Extensions.RulesBuilderExtensions.AddSqlCommandRules(RulesBuilder)"/><br/>
/// <see cref="ServiceCollectionExtensions.ConfigureSqlApi(IServiceCollection)"/><br/>
/// </code>
/// </summary>
Expand All @@ -300,7 +301,7 @@ public static RouteHandlerBuilder MapSqlApiGetDeleteBatchSQL(this IEndpointRoute
/// Returns generated SQL statement.<br/><br/>
/// <i><b>Requires calls to:</b></i>
/// <code>
/// <see cref="TypeCache.Extensions.ServiceCollectionExtensions.AddSqlCommandRules(IServiceCollection)"/><br/>
/// <see cref="TypeCache.Extensions.RulesBuilderExtensions.AddSqlCommandRules(RulesBuilder)"/><br/>
/// <see cref="ServiceCollectionExtensions.ConfigureSqlApi(IServiceCollection)"/><br/>
/// </code>
/// </summary>
Expand All @@ -315,7 +316,7 @@ public static RouteHandlerBuilder MapSqlApiGetInsertSQL(this IEndpointRouteBuild
/// Returns generated SQL statement.<br/><br/>
/// <i><b>Requires calls to:</b></i>
/// <code>
/// <see cref="TypeCache.Extensions.ServiceCollectionExtensions.AddSqlCommandRules(IServiceCollection)"/><br/>
/// <see cref="TypeCache.Extensions.RulesBuilderExtensions.AddSqlCommandRules(RulesBuilder)"/><br/>
/// <see cref="ServiceCollectionExtensions.ConfigureSqlApi(IServiceCollection)"/><br/>
/// </code>
/// </summary>
Expand All @@ -329,7 +330,7 @@ public static RouteHandlerBuilder MapSqlApiGetInsertBatchSQL(this IEndpointRoute
/// Returns generated SQL statement.<br/><br/>
/// <i><b>Requires calls to:</b></i>
/// <code>
/// <see cref="TypeCache.Extensions.ServiceCollectionExtensions.AddSqlCommandRules(IServiceCollection)"/><br/>
/// <see cref="TypeCache.Extensions.RulesBuilderExtensions.AddSqlCommandRules(RulesBuilder)"/><br/>
/// <see cref="ServiceCollectionExtensions.ConfigureSqlApi(IServiceCollection)"/><br/>
/// </code>
/// </summary>
Expand All @@ -343,7 +344,7 @@ public static RouteHandlerBuilder MapSqlApiGetSelectTableSQL(this IEndpointRoute
/// Returns generated SQL statement.<br/><br/>
/// <i><b>Requires calls to:</b></i>
/// <code>
/// <see cref="TypeCache.Extensions.ServiceCollectionExtensions.AddSqlCommandRules(IServiceCollection)"/><br/>
/// <see cref="TypeCache.Extensions.RulesBuilderExtensions.AddSqlCommandRules(RulesBuilder)"/><br/>
/// <see cref="ServiceCollectionExtensions.ConfigureSqlApi(IServiceCollection)"/><br/>
/// </code>
/// </summary>
Expand All @@ -357,7 +358,7 @@ public static RouteHandlerBuilder MapSqlApiGetSelectViewSQL(this IEndpointRouteB
/// Returns generated SQL statement.<br/><br/>
/// <i><b>Requires calls to:</b></i>
/// <code>
/// <see cref="TypeCache.Extensions.ServiceCollectionExtensions.AddSqlCommandRules(IServiceCollection)"/><br/>
/// <see cref="TypeCache.Extensions.RulesBuilderExtensions.AddSqlCommandRules(RulesBuilder)"/><br/>
/// <see cref="ServiceCollectionExtensions.ConfigureSqlApi(IServiceCollection)"/><br/>
/// </code>
/// </summary>
Expand All @@ -372,7 +373,7 @@ public static RouteHandlerBuilder MapSqlApiGetUpdateSQL(this IEndpointRouteBuild
/// Returns generated SQL statement.<br/><br/>
/// <i><b>Requires calls to:</b></i>
/// <code>
/// <see cref="TypeCache.Extensions.ServiceCollectionExtensions.AddSqlCommandRules(IServiceCollection)"/><br/>
/// <see cref="TypeCache.Extensions.RulesBuilderExtensions.AddSqlCommandRules(RulesBuilder)"/><br/>
/// <see cref="ServiceCollectionExtensions.ConfigureSqlApi(IServiceCollection)"/><br/>
/// </code>
/// </summary>
Expand All @@ -385,7 +386,7 @@ public static RouteHandlerBuilder MapSqlApiGetUpdateBatchSQL(this IEndpointRoute
/// <c>POST /{{dataSource:string}}/table/{{database:string}}/{{schema:string}}/{{table:string}}</c><br/><br/>
/// <i><b>Requires calls to:</b></i>
/// <code>
/// <see cref="TypeCache.Extensions.ServiceCollectionExtensions.AddSqlCommandRules(IServiceCollection)"/><br/>
/// <see cref="TypeCache.Extensions.RulesBuilderExtensions.AddSqlCommandRules(RulesBuilder)"/><br/>
/// <see cref="ServiceCollectionExtensions.ConfigureSqlApi(IServiceCollection)"/><br/>
/// </code>
/// </summary>
Expand All @@ -399,7 +400,7 @@ public static RouteHandlerBuilder MapSqlApiInsert(this IEndpointRouteBuilder @th
/// Body is an array of data whose property names match the primary keys of the table to delete from.<br/><br/>
/// <i><b>Requires calls to:</b></i>
/// <code>
/// <see cref="TypeCache.Extensions.ServiceCollectionExtensions.AddSqlCommandRules(IServiceCollection)"/><br/>
/// <see cref="TypeCache.Extensions.RulesBuilderExtensions.AddSqlCommandRules(RulesBuilder)"/><br/>
/// <see cref="ServiceCollectionExtensions.ConfigureSqlApi(IServiceCollection)"/><br/>
/// </code>
/// </summary>
Expand All @@ -413,7 +414,7 @@ public static RouteHandlerBuilder MapSqlApiInsertBatch(this IEndpointRouteBuilde
/// Gets database schema data.
/// <i><b>Requires calls to:</b></i>
/// <code>
/// <see cref="TypeCache.Extensions.ServiceCollectionExtensions.AddSqlCommandRules(IServiceCollection)"/><br/>
/// <see cref="TypeCache.Extensions.RulesBuilderExtensions.AddSqlCommandRules(RulesBuilder)"/><br/>
/// <see cref="ServiceCollectionExtensions.ConfigureSqlApi(IServiceCollection)"/><br/>
/// </code>
/// </summary>
Expand All @@ -427,7 +428,7 @@ public static RouteHandlerBuilder MapSqlApiSchemaGet(this IEndpointRouteBuilder
/// Selects, filters, sorts and pages data from a table or view.<br/><br/>
/// <i><b>Requires calls to:</b></i>
/// <code>
/// <see cref="TypeCache.Extensions.ServiceCollectionExtensions.AddSqlCommandRules(IServiceCollection)"/><br/>
/// <see cref="TypeCache.Extensions.RulesBuilderExtensions.AddSqlCommandRules(RulesBuilder)"/><br/>
/// <see cref="ServiceCollectionExtensions.ConfigureSqlApi(IServiceCollection)"/><br/>
/// </code>
/// </summary>
Expand All @@ -441,7 +442,7 @@ public static RouteHandlerBuilder MapSqlApiSelectTable(this IEndpointRouteBuilde
/// Selects, filters, sorts and pages data from a view.<br/><br/>
/// <i><b>Requires calls to:</b></i>
/// <code>
/// <see cref="TypeCache.Extensions.ServiceCollectionExtensions.AddSqlCommandRules(IServiceCollection)"/><br/>
/// <see cref="TypeCache.Extensions.RulesBuilderExtensions.AddSqlCommandRules(RulesBuilder)"/><br/>
/// <see cref="ServiceCollectionExtensions.ConfigureSqlApi(IServiceCollection)"/><br/>
/// </code>
/// </summary>
Expand All @@ -455,7 +456,7 @@ public static RouteHandlerBuilder MapSqlApiSelectView(this IEndpointRouteBuilder
/// Updates table data.<br/><br/>
/// <i><b>Requires calls to:</b></i>
/// <code>
/// <see cref="TypeCache.Extensions.ServiceCollectionExtensions.AddSqlCommandRules(IServiceCollection)"/><br/>
/// <see cref="TypeCache.Extensions.RulesBuilderExtensions.AddSqlCommandRules(RulesBuilder)"/><br/>
/// <see cref="ServiceCollectionExtensions.ConfigureSqlApi(IServiceCollection)"/><br/>
/// </code>
/// </summary>
Expand All @@ -470,7 +471,7 @@ public static RouteHandlerBuilder MapSqlApiUpdate(this IEndpointRouteBuilder @th
/// Body is an array of data that contains values to update in the table.<br/><br/>
/// <i><b>Requires calls to:</b></i>
/// <code>
/// <see cref="TypeCache.Extensions.ServiceCollectionExtensions.AddSqlCommandRules(IServiceCollection)"/><br/>
/// <see cref="TypeCache.Extensions.RulesBuilderExtensions.AddSqlCommandRules(RulesBuilder)"/><br/>
/// <see cref="ServiceCollectionExtensions.ConfigureSqlApi(IServiceCollection)"/><br/>
/// </code>
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion src/TypeCache.Web/TypeCache.Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<Nullable>enable</Nullable>
<RootNamespace>TypeCache.Web</RootNamespace>
<PackageId>TypeCache.Web</PackageId>
<Version>8.1.0</Version>
<Version>8.1.1</Version>
<Authors>Samuel Abraham &lt;sam987883@gmail.com&gt;</Authors>
<Company>Samuel Abraham &lt;sam987883@gmail.com&gt;</Company>
<Title>TypeCache Web Library</Title>
Expand Down
9 changes: 7 additions & 2 deletions src/TypeCache/Data/DataSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace TypeCache.Data;

internal sealed class DataSource : IDataSource
{
public DataSource(string name, DbProviderFactory dbProviderFactory, string connectionString)
public DataSource(string name, DbProviderFactory dbProviderFactory, string connectionString, string[] databases)
{
this.Factory = dbProviderFactory;
this.Name = name;
Expand Down Expand Up @@ -66,7 +66,12 @@ _ when @namespace.Is("MySql.Data.MySqlClient") => DataSourceType.MySql,
.WhereNotNull()
.ToFrozenSet();

this.Databases = this.GetDatabases().ToFrozenSet(StringComparer.OrdinalIgnoreCase);
if (databases?.Length > 0)
this.Databases = new HashSet<string>(databases, StringComparer.OrdinalIgnoreCase)
.ToFrozenSet(StringComparer.OrdinalIgnoreCase);
else
this.Databases = this.GetDatabases().ToFrozenSet(StringComparer.OrdinalIgnoreCase);

this.ObjectSchemas = this.GetObjectSchemas();
}

Expand Down
9 changes: 1 addition & 8 deletions src/TypeCache/Extensions/BitConverterExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public static double ToDouble(this ReadOnlySpan<byte> @this)
public static double ToDouble(this byte[] @this, int startIndex = 0)
=> BitConverter.ToDouble(@this, startIndex);

/// <inheritdoc cref="BitConverter.Int16BitsToHalf(ushort)"/>
/// <inheritdoc cref="BitConverter.Int16BitsToHalf(short)"/>
/// <remarks>
/// <c>=&gt; <see cref="BitConverter"/>.Int16BitsToHalf(@<paramref name="this"/>);</c>
/// </remarks>
Expand All @@ -162,13 +162,6 @@ public static Half ToHalf(this short @this)
public static Half ToHalf(this ushort @this)
=> BitConverter.UInt16BitsToHalf(@this);

/// <inheritdoc cref="BitConverter.Int16BitsToHalf(short)"/>
/// <remarks>
/// <c>=&gt; <see cref="BitConverter"/>.Int16BitsToHalf(@<paramref name="this"/>);</c>
/// </remarks>
public static Half ToInt16(this short @this)
=> BitConverter.Int16BitsToHalf(@this);

/// <inheritdoc cref="BitConverter.ToInt16(ReadOnlySpan{byte})"/>
/// <remarks>
/// <c>=&gt; <see cref="BitConverter"/>.ToInt16(@<paramref name="this"/>.Span);</c>
Expand Down
2 changes: 1 addition & 1 deletion src/TypeCache/Extensions/EnumerableExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public static bool ContainsEnum<T>(this IEnumerable<T> @this, T value)
public static string Concat(this IEnumerable<string> @this)
=> string.Concat(@this);

/// <inheritdoc cref="string.Concat(IEnumerable{char})"/>
/// <inheritdoc cref="string.Concat{T}(IEnumerable{T})"/>
/// <remarks>
/// <c>=&gt; <see cref="string"/>.Concat(@<paramref name="this"/>);</c>
/// </remarks>
Expand Down
4 changes: 2 additions & 2 deletions src/TypeCache/Extensions/ReflectionExtensions.Type.cs
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ public static bool IsConvertible(this Type @this)
=> @this.IsAssignableTo<IConvertible>()
|| (@this.Is(typeof(Nullable<>)) && @this.GenericTypeArguments.First().IsAssignableTo<IConvertible>());

/// <exception cref=""/>
/// <exception cref="ArgumentNullException"/>
public static bool IsConvertibleTo(this Type @this, Type targetType)
{
@this.AssertNotNull();
Expand Down Expand Up @@ -440,7 +440,7 @@ public static LabelTarget ToLabelTarget(this Type @this)
public static LabelTarget ToLabelTarget(this Type @this, string? name)
=> Expression.Label(@this, name);

/// <inheritdoc cref="Expression.New(ConstructorInfo, Expression[]?)"/>
/// <inheritdoc cref="Expression.New(ConstructorInfo, Expression[])"/>
[DebuggerHidden]
public static NewExpression ToNewExpression(this Type @this, params Expression[] parameters) => parameters switch
{
Expand Down
4 changes: 2 additions & 2 deletions src/TypeCache/Extensions/ServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ public static class ServiceCollectionExtensions
/// <summary>
/// Registers keyed singleton <c><see cref="IDataSource"/></c>.<br/>
/// </summary>
public static IServiceCollection AddDataSource(this IServiceCollection @this, string name, DbProviderFactory dbProviderFactory, string connectionString)
=> @this.AddKeyedSingleton<IDataSource>(name, new DataSource(name, dbProviderFactory, connectionString));
public static IServiceCollection AddDataSource(this IServiceCollection @this, string name, DbProviderFactory dbProviderFactory, string connectionString, string[] databases)
=> @this.AddKeyedSingleton<IDataSource>(name, new DataSource(name, dbProviderFactory, connectionString, databases));

/// <summary>
/// Registers Singletons:
Expand Down
4 changes: 2 additions & 2 deletions src/TypeCache/Extensions/SpanExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public static bool TryRead<T>(this scoped Span<byte> @this, out T value)
where T : struct
=> MemoryMarshal.TryRead(@this, out value);

/// <inheritdoc cref="MemoryMarshal.TryWrite{T}(Span{byte}, ref T)"/>
/// <inheritdoc cref="MemoryMarshal.TryWrite{T}(Span{byte}, in T)"/>
/// <remarks>
/// <c>=&gt; <see cref="MemoryMarshal"/>.TryWrite(@<paramref name="this"/>, <see langword="ref"/> <paramref name="value"/>);</c>
/// </remarks>
Expand All @@ -75,7 +75,7 @@ public static bool TryWrite<T>(this scoped Span<byte> @this, in T value)
where T : struct
=> MemoryMarshal.TryWrite(@this, in value);

/// <inheritdoc cref="MemoryMarshal.Write{T}(Span{byte}, ref T)"/>
/// <inheritdoc cref="MemoryMarshal.Write{T}(Span{byte}, in T)"/>
/// <remarks>
/// <c>=&gt; <see cref="MemoryMarshal"/>.Write(@<paramref name="this"/>, <see langword="ref"/> <paramref name="value"/>);</c>
/// </remarks>
Expand Down
2 changes: 1 addition & 1 deletion src/TypeCache/TypeCache.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<RootNamespace>TypeCache</RootNamespace>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<PackageId>TypeCache</PackageId>
<Version>8.1.0</Version>
<Version>8.1.1</Version>
<Authors>Samuel Abraham &lt;sam987883@gmail.com&gt;</Authors>
<Company>Samuel Abraham &lt;sam987883@gmail.com&gt;</Company>
<Title>TypeCache Reflection</Title>
Expand Down
4 changes: 1 addition & 3 deletions tests/TypeCache.GraphQL.TestApp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@

using GraphQL.Server.Ui.Playground;
using Microsoft.Data.SqlClient;
using Microsoft.Extensions.DependencyInjection;
using TypeCache.Attributes;
using TypeCache.Data;
using TypeCache.Extensions;
using TypeCache.GraphQL.Extensions;
using TypeCache.GraphQL.TestApp.Models;
using TypeCache.GraphQL.TestApp.Tables;
using TypeCache.Utilities;
using static System.Math;

const string DATASOURCE = "Default";
Expand All @@ -18,7 +16,7 @@
builder.Services
.AddMediation(builder => builder.AddSqlCommandRules())
.AddHashMaker((decimal)(Tau - E), (decimal)(Tau + 2 * E))
.AddDataSource(DATASOURCE, SqlClientFactory.Instance, builder.Configuration.GetConnectionString(DATASOURCE)!)
.AddDataSource(DATASOURCE, SqlClientFactory.Instance, builder.Configuration.GetConnectionString(DATASOURCE)!, ["AdventureWorks2019"])
.AddGraphQL()
.AddGraphQLTypeExtensions<Person>(person =>
{
Expand Down

0 comments on commit b125773

Please sign in to comment.