Remove pragma warning disable 1998

Function doesn't need async
This commit is contained in:
Ben Adams 2016-05-12 20:41:47 +01:00 коммит произвёл Ryan Nowak
Родитель cdea6fd3fb
Коммит cacd16fa85
3 изменённых файлов: 29 добавлений и 4 удалений

Просмотреть файл

@ -0,0 +1,24 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Threading.Tasks;
namespace Microsoft.AspNetCore.Razor.Internal
{
public static class TaskCache
{
/// <summary>
/// A <see cref="Task"/> that's already completed successfully.
/// </summary>
/// <remarks>
/// We're caching this in a static readonly field to make it more inlinable and avoid the volatile lookup done
/// by <c>Task.CompletedTask</c>.
/// </remarks>
#if NET451
public static readonly Task CompletedTask = Task.FromResult(0);
#else
public static readonly Task CompletedTask = Task.CompletedTask;
#endif
}
}

Просмотреть файл

@ -6,6 +6,7 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.Text.Encodings.Web;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor.Internal;
using Microsoft.AspNetCore.Razor.TagHelpers;
namespace Microsoft.AspNetCore.Razor.Runtime.TagHelpers
@ -31,7 +32,7 @@ namespace Microsoft.AspNetCore.Razor.Runtime.TagHelpers
tagMode,
items: new Dictionary<object, object>(),
uniqueId: string.Empty,
executeChildContentAsync: async () => await Task.FromResult(result: true),
executeChildContentAsync: () => TaskCache.CompletedTask,
startTagHelperWritingScope: _ => { },
endTagHelperWritingScope: () => new DefaultTagHelperContent())
{

Просмотреть файл

@ -2,6 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor.Internal;
namespace Microsoft.AspNetCore.Razor.TagHelpers
{
@ -37,11 +38,10 @@ namespace Microsoft.AspNetCore.Razor.TagHelpers
/// <param name="output">A stateful HTML element used to generate an HTML tag.</param>
/// <returns>A <see cref="Task"/> that on completion updates the <paramref name="output"/>.</returns>
/// <remarks>By default this calls into <see cref="Process"/>.</remarks>.
#pragma warning disable 1998
public virtual async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
public virtual Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
{
Process(context, output);
return TaskCache.CompletedTask;
}
#pragma warning restore 1998
}
}