Skip to content
This repository was archived by the owner on Dec 14, 2018. It is now read-only.

Commit 9342cb0

Browse files
committed
Suppress [Obsolete] warnings from DiagnosticSource
1 parent 91cb628 commit 9342cb0

File tree

14 files changed

+68
-10
lines changed

14 files changed

+68
-10
lines changed

src/Microsoft.AspNet.Mvc.Core/Controllers/ControllerActionInvoker.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public class ControllerActionInvoker : FilterActionInvoker
2323
private readonly ControllerActionDescriptor _descriptor;
2424
private readonly IControllerFactory _controllerFactory;
2525
private readonly IControllerActionArgumentBinder _argumentBinder;
26-
26+
#pragma warning disable 0618
2727
public ControllerActionInvoker(
2828
ActionContext actionContext,
2929
IReadOnlyList<IFilterProvider> filterProviders,
@@ -129,6 +129,7 @@ public ControllerActionInvoker(
129129
"descriptor");
130130
}
131131
}
132+
#pragma warning disable 0618
132133

133134
protected override object CreateInstance()
134135
{

src/Microsoft.AspNet.Mvc.Core/Controllers/ControllerActionInvokerProvider.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ namespace Microsoft.AspNet.Mvc.Controllers
1818
{
1919
public class ControllerActionInvokerProvider : IActionInvokerProvider
2020
{
21+
#pragma warning disable 0618
2122
private readonly IControllerActionArgumentBinder _argumentBinder;
2223
private readonly IControllerFactory _controllerFactory;
2324
private readonly IFilterProvider[] _filterProviders;
@@ -53,6 +54,7 @@ public ControllerActionInvokerProvider(
5354
_logger = loggerFactory.CreateLogger<ControllerActionInvoker>();
5455
_telemetry = telemetry;
5556
}
57+
#pragma warning restore 0618
5658

5759
public int Order
5860
{

src/Microsoft.AspNet.Mvc.Core/Controllers/FilterActionInvoker.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ public abstract class FilterActionInvoker : IActionInvoker
3131
private readonly IReadOnlyList<IValueProviderFactory> _valueProviderFactories;
3232
private readonly IActionBindingContextAccessor _actionBindingContextAccessor;
3333
private readonly ILogger _logger;
34+
#pragma warning disable 0618
3435
private readonly TelemetrySource _telemetry;
36+
#pragma warning restore 0618
3537
private readonly int _maxModelValidationErrors;
3638

3739
private IFilterMetadata[] _filters;
@@ -61,6 +63,7 @@ public abstract class FilterActionInvoker : IActionInvoker
6163
private const string ResultFilterShortCircuitLogMessage =
6264
"Request was short circuited at result filter '{ResultFilter}'.";
6365

66+
#pragma warning disable 0618
6467
public FilterActionInvoker(
6568
ActionContext actionContext,
6669
IReadOnlyList<IFilterProvider> filterProviders,
@@ -137,6 +140,7 @@ public FilterActionInvoker(
137140
_telemetry = telemetry;
138141
_maxModelValidationErrors = maxModelValidationErrors;
139142
}
143+
#pragma warning restore 0618
140144

141145
protected ActionContext ActionContext { get; private set; }
142146

@@ -652,6 +656,7 @@ private async Task<ActionExecutedContext> InvokeActionFilterAsync()
652656

653657
try
654658
{
659+
#pragma warning disable 0618
655660
if (_telemetry.IsEnabled("Microsoft.AspNet.Mvc.BeforeActionMethod"))
656661
{
657662
_telemetry.WriteTelemetry(
@@ -663,11 +668,13 @@ private async Task<ActionExecutedContext> InvokeActionFilterAsync()
663668
controller = _actionExecutingContext.Controller
664669
});
665670
}
671+
#pragma warning restore 0618
666672

667673
result = await InvokeActionAsync(_actionExecutingContext);
668674
}
669675
finally
670676
{
677+
#pragma warning disable 0618
671678
if (_telemetry.IsEnabled("Microsoft.AspNet.Mvc.AfterActionMethod"))
672679
{
673680
_telemetry.WriteTelemetry(
@@ -680,6 +687,7 @@ private async Task<ActionExecutedContext> InvokeActionFilterAsync()
680687
result = result
681688
});
682689
}
690+
#pragma warning restore 0618
683691
}
684692

685693
_actionExecutedContext = new ActionExecutedContext(
@@ -827,25 +835,29 @@ private async Task<ResultExecutedContext> InvokeResultFilterAsync()
827835

828836
private async Task InvokeResultAsync(IActionResult result)
829837
{
838+
#pragma warning disable 0618
830839
if (_telemetry.IsEnabled("Microsoft.AspNet.Mvc.BeforeActionResult"))
831840
{
832841
_telemetry.WriteTelemetry(
833842
"Microsoft.AspNet.Mvc.BeforeActionResult",
834843
new { actionContext = ActionContext, result = result });
835844
}
845+
#pragma warning restore 0618
836846

837847
try
838848
{
839849
await result.ExecuteResultAsync(ActionContext);
840850
}
841851
finally
842852
{
853+
#pragma warning disable 0618
843854
if (_telemetry.IsEnabled("Microsoft.AspNet.Mvc.AfterActionResult"))
844855
{
845856
_telemetry.WriteTelemetry(
846857
"Microsoft.AspNet.Mvc.AfterActionResult",
847858
new { actionContext = ActionContext, result = result });
848859
}
860+
#pragma warning restore 0618
849861
}
850862
}
851863

src/Microsoft.AspNet.Mvc.Core/Infrastructure/MvcRouteHandler.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ public class MvcRouteHandler : IRouter
2020
private IActionInvokerFactory _actionInvokerFactory;
2121
private IActionSelector _actionSelector;
2222
private ILogger _logger;
23+
#pragma warning disable 0618
2324
private TelemetrySource _telemetry;
25+
#pragma warning restore 0618
2426

2527
public VirtualPathData GetVirtualPath(VirtualPathContext context)
2628
{
@@ -80,12 +82,14 @@ public async Task RouteAsync(RouteContext context)
8082
{
8183
context.RouteData = newRouteData;
8284

85+
#pragma warning disable 0618
8386
if (_telemetry.IsEnabled("Microsoft.AspNet.Mvc.BeforeAction"))
8487
{
8588
_telemetry.WriteTelemetry(
8689
"Microsoft.AspNet.Mvc.BeforeAction",
8790
new { actionDescriptor, httpContext = context.HttpContext, routeData = context.RouteData });
8891
}
92+
#pragma warning restore 0618
8993

9094
using (_logger.BeginScope("ActionId: {ActionId}", actionDescriptor.Id))
9195
{
@@ -97,12 +101,14 @@ public async Task RouteAsync(RouteContext context)
97101
}
98102
finally
99103
{
104+
#pragma warning disable 0618
100105
if (_telemetry.IsEnabled("Microsoft.AspNet.Mvc.AfterAction"))
101106
{
102107
_telemetry.WriteTelemetry(
103108
"Microsoft.AspNet.Mvc.AfterAction",
104109
new { actionDescriptor, httpContext = context.HttpContext, routeData = context.RouteData });
105110
}
111+
#pragma warning restore 0618
106112

107113
if (!context.IsHandled)
108114
{
@@ -150,10 +156,12 @@ private void EnsureServices(HttpContext context)
150156
_logger = factory.CreateLogger<MvcRouteHandler>();
151157
}
152158

159+
#pragma warning disable 0618
153160
if (_telemetry == null)
154161
{
155162
_telemetry = context.RequestServices.GetRequiredService<TelemetrySource>();
156163
}
164+
#pragma warning restore 0618
157165
}
158166
}
159167
}

src/Microsoft.AspNet.Mvc.ViewFeatures/ViewFeatures/PartialViewResultExecutor.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
1616
/// </summary>
1717
public class PartialViewResultExecutor : ViewExecutor
1818
{
19+
#pragma warning disable 0618
1920
/// <summary>
2021
/// Creates a new <see cref="PartialViewResultExecutor"/>.
2122
/// </summary>
@@ -39,6 +40,7 @@ public PartialViewResultExecutor(
3940

4041
Logger = loggerFactory.CreateLogger<PartialViewResultExecutor>();
4142
}
43+
#pragma warning restore 0618
4244

4345
/// <summary>
4446
/// Gets the <see cref="ILogger"/>.
@@ -69,6 +71,7 @@ public virtual ViewEngineResult FindView(ActionContext actionContext, PartialVie
6971
var result = viewEngine.FindPartialView(actionContext, viewName);
7072
if (result.Success)
7173
{
74+
#pragma warning disable 0618
7275
if (Telemetry.IsEnabled("Microsoft.AspNet.Mvc.ViewFound"))
7376
{
7477
Telemetry.WriteTelemetry(
@@ -82,11 +85,12 @@ public virtual ViewEngineResult FindView(ActionContext actionContext, PartialVie
8285
view = result.View,
8386
});
8487
}
85-
88+
#pragma warning restore 0618
8689
Logger.LogVerbose("The partial view '{PartialViewName}' was found.", viewName);
8790
}
8891
else
8992
{
93+
#pragma warning disable 0618
9094
if (Telemetry.IsEnabled("Microsoft.AspNet.Mvc.ViewNotFound"))
9195
{
9296
Telemetry.WriteTelemetry(
@@ -100,6 +104,7 @@ public virtual ViewEngineResult FindView(ActionContext actionContext, PartialVie
100104
searchedLocations = result.SearchedLocations
101105
});
102106
}
107+
#pragma warning restore 0618
103108

104109
Logger.LogError(
105110
"The partial view '{PartialViewName}' was not found. Searched locations: {SearchedViewLocations}",

src/Microsoft.AspNet.Mvc.ViewFeatures/ViewFeatures/ViewExecutor.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public class ViewExecutor
2626
Encoding = Encoding.UTF8
2727
}.CopyAsReadOnly();
2828

29+
#pragma warning disable 0618
2930
/// <summary>
3031
/// Creates a new <see cref="ViewExecutor"/>.
3132
/// </summary>
@@ -69,6 +70,7 @@ public ViewExecutor(
6970
/// Gets the <see cref="TelemetrySource"/>.
7071
/// </summary>
7172
protected TelemetrySource Telemetry { get; }
73+
#pragma warning restore 0618
7274

7375
/// <summary>
7476
/// Gets the default <see cref="IViewEngine"/>.
@@ -158,21 +160,25 @@ public virtual async Task ExecuteAsync(
158160
writer,
159161
ViewOptions.HtmlHelperOptions);
160162

163+
#pragma warning disable 0618
161164
if (Telemetry.IsEnabled("Microsoft.AspNet.Mvc.BeforeView"))
162165
{
163166
Telemetry.WriteTelemetry(
164167
"Microsoft.AspNet.Mvc.BeforeView",
165168
new { view = view, viewContext = viewContext, });
166169
}
170+
#pragma warning restore 0618
167171

168172
await view.RenderAsync(viewContext);
169173

174+
#pragma warning disable 0618
170175
if (Telemetry.IsEnabled("Microsoft.AspNet.Mvc.AfterView"))
171176
{
172177
Telemetry.WriteTelemetry(
173178
"Microsoft.AspNet.Mvc.AfterView",
174179
new { view = view, viewContext = viewContext, });
175180
}
181+
#pragma warning restore 0618
176182

177183
// Perf: Invoke FlushAsync to ensure any buffered content is asynchronously written to the underlying
178184
// response asynchronously. In the absence of this line, the buffer gets synchronously written to the

src/Microsoft.AspNet.Mvc.ViewFeatures/ViewFeatures/ViewResultExecutor.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
1616
/// </summary>
1717
public class ViewResultExecutor : ViewExecutor
1818
{
19+
#pragma warning disable 0618
1920
/// <summary>
2021
/// Creates a new <see cref="ViewResultExecutor"/>.
2122
/// </summary>
@@ -39,6 +40,7 @@ public ViewResultExecutor(
3940

4041
Logger = loggerFactory.CreateLogger<ViewResultExecutor>();
4142
}
43+
#pragma warning restore 0618
4244

4345
/// <summary>
4446
/// Gets the <see cref="ILogger"/>.
@@ -69,6 +71,7 @@ public virtual ViewEngineResult FindView(ActionContext actionContext, ViewResult
6971
var result = viewEngine.FindView(actionContext, viewName);
7072
if (result.Success)
7173
{
74+
#pragma warning disable 0618
7275
if (Telemetry.IsEnabled("Microsoft.AspNet.Mvc.ViewFound"))
7376
{
7477
Telemetry.WriteTelemetry(
@@ -82,11 +85,13 @@ public virtual ViewEngineResult FindView(ActionContext actionContext, ViewResult
8285
view = result.View,
8386
});
8487
}
88+
#pragma warning restore 0618
8589

8690
Logger.LogVerbose("The view '{ViewName}' was found.", viewName);
8791
}
8892
else
8993
{
94+
#pragma warning disable 0618
9095
if (Telemetry.IsEnabled("Microsoft.AspNet.Mvc.ViewNotFound"))
9196
{
9297
Telemetry.WriteTelemetry(
@@ -100,6 +105,7 @@ public virtual ViewEngineResult FindView(ActionContext actionContext, ViewResult
100105
searchedLocations = result.SearchedLocations
101106
});
102107
}
108+
#pragma warning restore 0618
103109

104110
Logger.LogError(
105111
"The view '{ViewName}' was not found. Searched locations: {SearchedViewLocations}",

test/Microsoft.AspNet.Mvc.Core.Test/Controllers/ControllerActionInvokerTest.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2041,7 +2041,7 @@ private TestControllerActionInvoker CreateInvoker(
20412041
filterProvider
20422042
.SetupGet(fp => fp.Order)
20432043
.Returns(-1000);
2044-
2044+
#pragma warning disable 0618
20452045
var invoker = new TestControllerActionInvoker(
20462046
actionContext,
20472047
new[] { filterProvider.Object },
@@ -2057,7 +2057,7 @@ private TestControllerActionInvoker CreateInvoker(
20572057
new NullLoggerFactory().CreateLogger<ControllerActionInvoker>(),
20582058
new TelemetryListener("Microsoft.AspNet"),
20592059
maxAllowedErrorsInModelState);
2060-
2060+
#pragma warning restore 0618
20612061
return invoker;
20622062
}
20632063

@@ -2101,6 +2101,7 @@ public async Task Invoke_UsesDefaultValuesIfNotBound()
21012101
.Returns(new TestController());
21022102

21032103
var metadataProvider = new EmptyModelMetadataProvider();
2104+
#pragma warning disable 0618
21042105
var invoker = new ControllerActionInvoker(
21052106
actionContext,
21062107
new List<IFilterProvider>(),
@@ -2118,6 +2119,7 @@ public async Task Invoke_UsesDefaultValuesIfNotBound()
21182119
new NullLoggerFactory().CreateLogger<ControllerActionInvoker>(),
21192120
new TelemetryListener("Microsoft.AspNet"),
21202121
200);
2122+
#pragma warning restore 0618
21212123

21222124
// Act
21232125
await invoker.InvokeAsync();
@@ -2204,6 +2206,7 @@ public void Verify()
22042206

22052207
private class TestControllerActionInvoker : ControllerActionInvoker
22062208
{
2209+
#pragma warning disable 0618
22072210
public TestControllerActionInvoker(
22082211
ActionContext actionContext,
22092212
IFilterProvider[] filterProvider,
@@ -2237,6 +2240,7 @@ public TestControllerActionInvoker(
22372240
{
22382241
ControllerFactory = controllerFactory;
22392242
}
2243+
#pragma warning restore 0618
22402244

22412245
public MockControllerFactory ControllerFactory { get; }
22422246

test/Microsoft.AspNet.Mvc.Core.Test/Infrastructure/MvcRouteHandlerTests.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,13 +242,13 @@ private RouteContext CreateRouteContext(
242242
{
243243
optionsAccessor = new TestOptionsManager<MvcOptions>();
244244
}
245-
245+
#pragma warning disable 0618
246246
var telemetry = new TelemetryListener("Microsoft.AspNet");
247247
if (telemetryListener != null)
248248
{
249249
telemetry.SubscribeWithAdapter(telemetryListener);
250250
}
251-
251+
#pragma warning restore 0618
252252
var httpContext = new Mock<HttpContext>();
253253
httpContext.Setup(h => h.RequestServices.GetService(typeof(IActionContextAccessor)))
254254
.Returns(new ActionContextAccessor());
@@ -262,9 +262,10 @@ private RouteContext CreateRouteContext(
262262
.Returns(new MvcMarkerService());
263263
httpContext.Setup(h => h.RequestServices.GetService(typeof(IOptions<MvcOptions>)))
264264
.Returns(optionsAccessor);
265+
#pragma warning disable 0618
265266
httpContext.Setup(h => h.RequestServices.GetService(typeof(TelemetrySource)))
266267
.Returns(telemetry);
267-
268+
#pragma warning restore 0618
268269
return new RouteContext(httpContext.Object);
269270
}
270271
}

test/Microsoft.AspNet.Mvc.ViewFeatures.Test/PartialViewResultTest.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,14 @@ private ActionContext GetActionContext()
105105
private HttpContext GetHttpContext()
106106
{
107107
var options = new TestOptionsManager<MvcViewOptions>();
108+
#pragma warning disable 0618
108109
var viewExecutor = new PartialViewResultExecutor(
109110
options,
110111
new TestHttpResponseStreamWriterFactory(),
111112
new CompositeViewEngine(options),
112113
new TelemetryListener("Microsoft.AspNet"),
113114
NullLoggerFactory.Instance);
115+
#pragma warning restore 0618
114116

115117
var services = new ServiceCollection();
116118
services.AddInstance(viewExecutor);

0 commit comments

Comments
 (0)