Skip to content

Commit b6507bb

Browse files
Merge pull request #34 from elsupergomez/fix-warning
Fix warning
2 parents 6a06a75 + 351bbdb commit b6507bb

File tree

5 files changed

+19
-18
lines changed

5 files changed

+19
-18
lines changed

src/MakingSense.AspNetCore.HypermediaApi/ApiMappers/ApiMapperExtensions.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,18 +59,16 @@ public static TOut Map<TIn, TOut>(this IApiMapper<TIn, TOut> mapper, TIn input)
5959
public static IEnumerable<TOut> Map<TIn, TOut>(this IApiMapper<TIn, TOut> mapper, IEnumerable<TIn> inputEnumerable)
6060
where TOut : class, new()
6161
{
62-
var queryableProyector = mapper as IQueryableMapper<TIn, TOut>;
6362
return
64-
queryableProyector != null ? queryableProyector.Map(inputEnumerable.AsQueryable())
63+
mapper is IQueryableMapper<TIn, TOut> queryableProyector ? queryableProyector.Map(inputEnumerable.AsQueryable())
6564
: inputEnumerable.Select(x => mapper.Map(x));
6665
}
6766

6867
public static IEnumerable<TOut> Map<TIn, TOut>(this IApiMapper<TIn, TOut> mapper, IQueryable<TIn> inputQueryable)
6968
where TOut : class, new()
7069
{
71-
var queryableProyector = mapper as IQueryableMapper<TIn, TOut>;
7270
return
73-
queryableProyector != null ? queryableProyector.Map(inputQueryable)
71+
mapper is IQueryableMapper<TIn, TOut> queryableProyector ? queryableProyector.Map(inputQueryable)
7472
: inputQueryable.AsEnumerable().Select(x => mapper.Map(x));
7573
}
7674

src/MakingSense.AspNetCore.HypermediaApi/Formatters/HypermediaApiJsonInputFormatter.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
using System;
22
using System.Buffers;
3-
using System.Collections.Generic;
4-
using System.Linq;
5-
using System.Threading.Tasks;
3+
using Microsoft.AspNetCore.Mvc;
64
using Microsoft.AspNetCore.Mvc.Formatters;
75
using Microsoft.Extensions.Logging;
86
using Microsoft.Extensions.ObjectPool;
@@ -17,8 +15,14 @@ public class HypermediaApiJsonInputFormatter : JsonInputFormatter
1715

1816
public bool AcceptAnyContentType { get; set; } = false;
1917

18+
[Obsolete("This constructor is obsolete and will be removed in a future version.")]
2019
public HypermediaApiJsonInputFormatter(ILogger logger, JsonSerializerSettings serializerSettings, ArrayPool<char> charPool, ObjectPoolProvider objectPoolProvider)
21-
: base(logger, serializerSettings, charPool, objectPoolProvider)
20+
: this(logger, serializerSettings, charPool, objectPoolProvider, null, null)
21+
{
22+
}
23+
24+
public HypermediaApiJsonInputFormatter(ILogger logger, JsonSerializerSettings serializerSettings, ArrayPool<char> charPool, ObjectPoolProvider objectPoolProvider, MvcOptions options, MvcJsonOptions jsonOptions)
25+
: base(logger, serializerSettings, charPool, objectPoolProvider, options, jsonOptions)
2226
{
2327
//TODO: add a setting to strict case sensitive de-serialization for properties
2428

src/MakingSense.AspNetCore.HypermediaApi/Formatters/Internal/HypermediaApiMvcOptionsSetup.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
using System;
22
using System.Buffers;
3-
using System.Collections.Generic;
4-
using System.Linq;
5-
using System.Threading.Tasks;
63
using Microsoft.AspNetCore.Mvc;
74
using Microsoft.AspNetCore.Mvc.Formatters;
85
using Microsoft.Extensions.Logging;
@@ -24,7 +21,8 @@ public HypermediaApiMvcOptionsSetup(
2421
jsonOptions.Value.SerializerSettings,
2522
loggerFactory,
2623
charPool,
27-
objectPoolProvider))
24+
objectPoolProvider,
25+
jsonOptions.Value))
2826
{
2927
}
3028

@@ -33,7 +31,8 @@ public static void ConfigureMvc(
3331
JsonSerializerSettings serializerSettings,
3432
ILoggerFactory loggerFactory,
3533
ArrayPool<char> charPool,
36-
ObjectPoolProvider objectPoolProvider)
34+
ObjectPoolProvider objectPoolProvider,
35+
MvcJsonOptions jsonOptions = null)
3736
{
3837
serializerSettings.Formatting = Formatting.Indented;
3938

@@ -49,7 +48,9 @@ public static void ConfigureMvc(
4948
jsonInputLogger,
5049
serializerSettings,
5150
charPool,
52-
objectPoolProvider));
51+
objectPoolProvider,
52+
options,
53+
jsonOptions));
5354
}
5455
}
5556
}

src/MakingSense.AspNetCore.HypermediaApi/Linking/BaseLinkHelper.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,9 @@ public Maybe<Link> ToAction(MethodInfo method, ReadOnlyCollection<Expression> ar
6767
var wrappedValues = Enumerable.Range(0, arguments.Count).Select(x =>
6868
{
6969
var argument = arguments[x];
70-
var unaryExpression = argument as UnaryExpression;
7170
TemplateParameter value;
7271

73-
if (unaryExpression != null && unaryExpression.Operand.Type.GetTypeInfo().IsSubclassOf(typeof(TemplateParameter)))
72+
if (argument is UnaryExpression unaryExpression && unaryExpression.Operand.Type.GetTypeInfo().IsSubclassOf(typeof(TemplateParameter)))
7473
{
7574
value = Expression.Lambda(unaryExpression.Operand).Compile().DynamicInvoke() as TemplateParameter;
7675
}

src/MakingSense.AspNetCore.HypermediaApi/ValidationFilters/RequiredPayloadFilter.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ public void OnActionExecuting([NotNull]ActionExecutingContext context)
2222
{
2323
if (context.ModelState.IsValid)
2424
{
25-
var actionDescriptor = context.ActionDescriptor as ControllerActionDescriptor;
26-
if (actionDescriptor == null)
25+
if (!(context.ActionDescriptor is ControllerActionDescriptor actionDescriptor))
2726
{
2827
return;
2928
}

0 commit comments

Comments
 (0)