Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Nate McMaster committed Mar 17, 2016
1 parent 9fd4a10 commit f9807e0
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 28 deletions.
1 change: 1 addition & 0 deletions GrefQL.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SIMPLE_EMBEDDED_STATEMENT_STYLE/@EntryValue">LINE_BREAK</s:String>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SPACE_AFTER_TYPECAST_PARENTHESES/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SPACE_AROUND_MULTIPLICATIVE_OP/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SPACE_BEFORE_TYPEOF_PARENTHESES/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SPACE_WITHIN_SINGLE_LINE_ARRAY_INITIALIZER_BRACES/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_AFTER_DECLARATION_LPAR/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_AFTER_INVOCATION_LPAR/@EntryValue">True</s:Boolean>
Expand Down
18 changes: 9 additions & 9 deletions src/GrefQL/Query/FieldResolverFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ public FieldResolverFactory(IGraphTypeMapper typeMapper)
private readonly IGraphTypeMapper _typeMapper;

private static readonly ParameterExpression _resolveFieldContextParameterExpression
= Expression.Parameter(typeof (ResolveFieldContext), "resolveFieldContext");
= Expression.Parameter(typeof(ResolveFieldContext), "resolveFieldContext");

private static readonly MethodInfo _efPropertyMethodInfo
= typeof (EF).GetTypeInfo().GetDeclaredMethod(nameof(Property));
= typeof(EF).GetTypeInfo().GetDeclaredMethod(nameof(Property));

private static readonly List<QueryArgument> _listArguments = new List<QueryArgument>
{
Expand Down Expand Up @@ -118,7 +118,7 @@ var resolveLambdaExpression
}

private static readonly MethodInfo _toArrayAsyncMethodInfo
= typeof (FieldResolverFactory).GetTypeInfo().GetDeclaredMethod(nameof(ToArrayAsync));
= typeof(FieldResolverFactory).GetTypeInfo().GetDeclaredMethod(nameof(ToArrayAsync));

private static Task<TEntity[]> ToArrayAsync<TEntity>(
ResolveFieldContext resolveFieldContext, IEntityType entityType)
Expand All @@ -127,7 +127,7 @@ private static Task<TEntity[]> ToArrayAsync<TEntity>(
.ToArrayAsync(resolveFieldContext.CancellationToken);

private static readonly MethodInfo _singleAsyncMethodInfo
= typeof (FieldResolverFactory).GetTypeInfo().GetDeclaredMethod(nameof(SingleAsync));
= typeof(FieldResolverFactory).GetTypeInfo().GetDeclaredMethod(nameof(SingleAsync));

private static Task<TEntity> SingleAsync<TEntity>(
ResolveFieldContext resolveFieldContext, IEntityType entityType)
Expand Down Expand Up @@ -162,7 +162,7 @@ private static IQueryable<TEntity> TryApplyFilters<TEntity>(
IEntityType entityType)
where TEntity : class
{
var entityParameterExpression = Expression.Parameter(typeof (TEntity), "entity");
var entityParameterExpression = Expression.Parameter(typeof(TEntity), "entity");

Expression predicateExpression = null;

Expand Down Expand Up @@ -218,7 +218,7 @@ private static IQueryable<TEntity> TryApplyOrderBy<TEntity>(
TryApplyArgument<object[]>(resolveFieldContext, OrderByArgumentName, orderBy =>
{
var firstOrdering = true;
var entityParameterExpression = Expression.Parameter(typeof (TEntity), "entity");
var entityParameterExpression = Expression.Parameter(typeof(TEntity), "entity");

// ReSharper disable once LoopCanBeConvertedToQuery
foreach (Dictionary<string, object> ordering in orderBy)
Expand All @@ -242,7 +242,7 @@ var propertyExpression

query = (IQueryable<TEntity>)
_applyOrderByMethodInfo
.MakeGenericMethod(typeof (TEntity), propertyExpression.Type)
.MakeGenericMethod(typeof(TEntity), propertyExpression.Type)
.Invoke(null, new object[]
{
query,
Expand All @@ -260,7 +260,7 @@ var propertyExpression
}

public static MethodInfo _applyOrderByMethodInfo
= typeof (FieldResolverFactory).GetTypeInfo().GetDeclaredMethod(nameof(ApplyOrderBy));
= typeof(FieldResolverFactory).GetTypeInfo().GetDeclaredMethod(nameof(ApplyOrderBy));

private static IQueryable<TEntity> ApplyOrderBy<TEntity, TKey>(
IOrderedQueryable<TEntity> query,
Expand Down Expand Up @@ -300,7 +300,7 @@ private static void TryApplyArgument<TArgument>(
}

private static readonly MethodInfo _tryAddArgumentFromSource
= typeof (FieldResolverFactory).GetTypeInfo().GetDeclaredMethod(nameof(TryAddArgumentFromSource));
= typeof(FieldResolverFactory).GetTypeInfo().GetDeclaredMethod(nameof(TryAddArgumentFromSource));

private static void TryAddArgumentFromSource(
ResolveFieldContext resolveFieldContext,
Expand Down
4 changes: 2 additions & 2 deletions src/GrefQL/Schema/GraphSchemaFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public ISchema Create(IModel model)

// ReSharper disable once InconsistentNaming
private static readonly MethodInfo _AddEntityType
= typeof (GraphSchemaFactory)
= typeof(GraphSchemaFactory)
.GetTypeInfo()
.GetDeclaredMethods(nameof(AddEntityField))
.Single(m => m.ContainsGenericParameters);
Expand All @@ -64,7 +64,7 @@ private void AddEntityField<TEntity>(GraphType query, IEntityType entityType, Fi

// ReSharper disable once InconsistentNaming
private static readonly MethodInfo _AddEntityTypeCollection
= typeof (GraphSchemaFactory)
= typeof(GraphSchemaFactory)
.GetTypeInfo()
.GetDeclaredMethods(nameof(AddEntityCollectionField))
.Single(m => m.ContainsGenericParameters);
Expand Down
2 changes: 1 addition & 1 deletion src/GrefQL/Schema/GraphTypeResolverSourceExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public static bool TryResolve<T>(this IGraphTypeResolverSource source, out T gra
where T : GraphType
{
graphType = default(T);
if (!source.Contains(typeof (T)))
if (!source.Contains(typeof(T)))
{
return false;
}
Expand Down
32 changes: 16 additions & 16 deletions test/GrefQL.Tests/FieldResolverFactoryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public async Task Create_resolver_when_entity_has_simple_key()
{
using (var context = CreateContext())
{
var customerType = context.Model.FindEntityType(typeof (Customer));
var customerType = context.Model.FindEntityType(typeof(Customer));

Assert.NotNull(customerType);

Expand All @@ -43,7 +43,7 @@ public async Task Create_resolver_when_entity_has_composite_key()
{
using (var context = CreateContext())
{
var orderDetailType = context.Model.FindEntityType(typeof (OrderDetail));
var orderDetailType = context.Model.FindEntityType(typeof(OrderDetail));

Assert.NotNull(orderDetailType);

Expand Down Expand Up @@ -73,14 +73,14 @@ public async Task Create_resolver_for_entities()
{
using (var context = CreateContext())
{
var customerType = context.Model.FindEntityType(typeof (Customer));
var customerType = context.Model.FindEntityType(typeof(Customer));

Assert.NotNull(customerType);

var fieldResolverFactory = new FieldResolverFactory(new GraphTypeMapper());

var resolver = fieldResolverFactory.CreateResolveEntityList(customerType);
Assert.All(resolver.Arguments, arg => Assert.False(typeof (NonNullGraphType).IsAssignableFrom(arg.Type)));
Assert.All(resolver.Arguments, arg => Assert.False(typeof(NonNullGraphType).IsAssignableFrom(arg.Type)));

var resolveFieldContext = new ResolveFieldContext
{
Expand All @@ -98,7 +98,7 @@ public async Task Create_resolver_for_entities_with_limit()
{
using (var context = CreateContext())
{
var customerType = context.Model.FindEntityType(typeof (Customer));
var customerType = context.Model.FindEntityType(typeof(Customer));

Assert.NotNull(customerType);

Expand All @@ -123,7 +123,7 @@ public async Task Create_resolver_for_entities_with_offset()
{
using (var context = CreateContext())
{
var customerType = context.Model.FindEntityType(typeof (Customer));
var customerType = context.Model.FindEntityType(typeof(Customer));

Assert.NotNull(customerType);

Expand All @@ -148,8 +148,8 @@ public async Task Create_resolver_for_one_to_many_from_dependent()
{
using (var context = CreateContext())
{
var orderType = context.Model.FindEntityType(typeof (Order));
var customerType = context.Model.FindEntityType(typeof (Customer));
var orderType = context.Model.FindEntityType(typeof(Order));
var customerType = context.Model.FindEntityType(typeof(Customer));
var orderToCustomer = Assert.Single(orderType.GetNavigations());
Assert.Equal(customerType, orderToCustomer.GetTargetType());

Expand All @@ -168,7 +168,7 @@ public async Task Create_resolver_for_one_to_many_from_dependent()

var resolveFieldContext = new ResolveFieldContext
{
RootValue = new QueryExecutionContext {DbContext = context},
RootValue = new QueryExecutionContext { DbContext = context },
Source = order,
Arguments = new Dictionary<string, object>()
};
Expand All @@ -183,8 +183,8 @@ public async Task Create_resolver_for_one_to_many_from_principal()
{
using (var context = CreateContext())
{
var orderType = context.Model.FindEntityType(typeof (Order));
var customerType = context.Model.FindEntityType(typeof (Customer));
var orderType = context.Model.FindEntityType(typeof(Order));
var customerType = context.Model.FindEntityType(typeof(Customer));
var customerToOrder = Assert.Single(customerType.GetNavigations());
Assert.Equal(orderType, customerToOrder.GetTargetType());

Expand All @@ -203,7 +203,7 @@ public async Task Create_resolver_for_one_to_many_from_principal()

var ordersContext = new ResolveFieldContext
{
RootValue = new QueryExecutionContext {DbContext = context},
RootValue = new QueryExecutionContext { DbContext = context },
Source = customer,
Arguments = new Dictionary<string, object>()
};
Expand All @@ -218,7 +218,7 @@ public async Task Create_resolver_for_entities_with_filter()
{
using (var context = CreateContext())
{
var customerType = context.Model.FindEntityType(typeof (Customer));
var customerType = context.Model.FindEntityType(typeof(Customer));

Assert.NotNull(customerType);

Expand All @@ -243,7 +243,7 @@ public async Task Create_resolver_for_entities_with_ordering()
{
using (var context = CreateContext())
{
var customerType = context.Model.FindEntityType(typeof (Customer));
var customerType = context.Model.FindEntityType(typeof(Customer));

Assert.NotNull(customerType);

Expand Down Expand Up @@ -276,7 +276,7 @@ public async Task Create_resolver_for_entities_with_ordering_descending()
{
using (var context = CreateContext())
{
var customerType = context.Model.FindEntityType(typeof (Customer));
var customerType = context.Model.FindEntityType(typeof(Customer));

Assert.NotNull(customerType);

Expand Down Expand Up @@ -313,7 +313,7 @@ public async Task Create_resolver_for_entities_with_multiple_orderings()
{
using (var context = CreateContext())
{
var customerType = context.Model.FindEntityType(typeof (Customer));
var customerType = context.Model.FindEntityType(typeof(Customer));

Assert.NotNull(customerType);

Expand Down

0 comments on commit f9807e0

Please sign in to comment.