Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions global.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"sdk": {
"version": "10.0.100-preview.4.25177.17"
"version": "10.0.100-preview.4.25180.3"
},
"tools": {
"dotnet": "10.0.100-preview.4.25177.17",
"dotnet": "10.0.100-preview.4.25180.3",
"runtimes": {
"dotnet/x86": [
"$(MicrosoftInternalRuntimeAspNetCoreTransportVersion)"
Expand Down
5 changes: 1 addition & 4 deletions src/Components/Server/src/Circuits/CircuitHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -828,10 +828,7 @@ await HandleInboundActivityAsync(() =>
operation.Descriptor.ComponentType,
operation.Marker.Value.Key,
operation.Descriptor.Parameters);
if (pendingTasks != null)
{
pendingTasks[i] = task;
}
pendingTasks?[i] = task;
break;
case RootComponentOperationType.Update:
// We don't need to await component updates as any unhandled exception will be reported and terminate the circuit.
Expand Down
15 changes: 3 additions & 12 deletions src/Hosting/Hosting/src/Http/DefaultHttpContextFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,7 @@ internal void Initialize(DefaultHttpContext httpContext, IFeatureCollection feat

httpContext.Initialize(featureCollection);

if (_httpContextAccessor != null)
{
_httpContextAccessor.HttpContext = httpContext;
}
_httpContextAccessor?.HttpContext = httpContext;

httpContext.FormOptions = _formOptions;
httpContext.ServiceScopeFactory = _serviceScopeFactory;
Expand All @@ -72,18 +69,12 @@ internal void Initialize(DefaultHttpContext httpContext, IFeatureCollection feat
/// </summary>
public void Dispose(HttpContext httpContext)
{
if (_httpContextAccessor != null)
{
_httpContextAccessor.HttpContext = null;
}
_httpContextAccessor?.HttpContext = null;
}

internal void Dispose(DefaultHttpContext httpContext)
{
if (_httpContextAccessor != null)
{
_httpContextAccessor.HttpContext = null;
}
_httpContextAccessor?.HttpContext = null;

httpContext.Uninitialize();
}
Expand Down
8 changes: 2 additions & 6 deletions src/Http/Http/src/HttpContextAccessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,8 @@ public HttpContext? HttpContext
}
set
{
var holder = _httpContextCurrent.Value;
if (holder != null)
{
// Clear current HttpContext trapped in the AsyncLocals, as its done.
holder.Context = null;
}
// Clear current HttpContext trapped in the AsyncLocals, as its done.
_httpContextCurrent.Value?.Context = null;

if (value != null)
{
Expand Down
6 changes: 1 addition & 5 deletions src/Middleware/Rewrite/src/RewriteMiddleware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,7 @@ public Task Invoke(HttpContext context)
// An endpoint may have already been set. Since we're going to re-invoke the middleware pipeline we need to reset
// the endpoint and route values to ensure things are re-calculated.
context.SetEndpoint(endpoint: null);
var routeValuesFeature = context.Features.Get<IRouteValuesFeature>();
if (routeValuesFeature is not null)
{
routeValuesFeature.RouteValues = null!;
}
context.Features.Get<IRouteValuesFeature>()?.RouteValues = null!;
return _options.BranchedNext(context);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,8 @@ public override void ApplyAction(RewriteContext context, BackReferenceCollection

if (!string.IsNullOrEmpty(StatusDescription))
{
var feature = context.HttpContext.Features.Get<IHttpBodyControlFeature>();
if (feature != null)
{
feature.AllowSynchronousIO = true;
}
context.HttpContext.Features.Get<IHttpBodyControlFeature>()?.AllowSynchronousIO = true;

var content = Encoding.UTF8.GetBytes(StatusDescription);
response.ContentLength = content.Length;
response.ContentType = "text/plain; charset=utf-8";
Expand Down
6 changes: 1 addition & 5 deletions src/Middleware/StaticFiles/src/StaticFileContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -407,11 +407,7 @@ private ContentRangeHeaderValue ComputeContentRange(RangeItemHeaderValue range,
// Only called when we expect to serve the body.
private void SetCompressionMode()
{
var responseCompressionFeature = _context.Features.Get<IHttpsCompressionFeature>();
if (responseCompressionFeature != null)
{
responseCompressionFeature.Mode = _options.HttpsCompression;
}
_context.Features.Get<IHttpsCompressionFeature>()?.Mode = _options.HttpsCompression;
}

internal enum PreconditionState : byte
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,12 +248,7 @@ protected virtual bool ValidateNode()
{
// If the field has an entry in ModelState, then record it as valid. Don't create
// extra entries if they don't exist already.
var entry = ModelState[Key];
if (entry != null)
{
entry.ValidationState = ModelValidationState.Valid;
}

ModelState[Key]?.ValidationState = ModelValidationState.Valid;
return true;
}
}
Expand Down
13 changes: 2 additions & 11 deletions src/Mvc/Mvc.ViewFeatures/src/Filters/SaveTempDataFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,7 @@ public void OnResourceExecuted(ResourceExecutedContext context)
// not be available.
if (!context.HttpContext.Response.HasStarted && context.Exception != null)
{
var saveTempDataContext = GetTempDataContext(context.HttpContext);
if (saveTempDataContext != null)
{
saveTempDataContext.RequestHasUnhandledException = true;
}
GetTempDataContext(context.HttpContext)?.RequestHasUnhandledException = true;
}
}

Expand All @@ -105,12 +101,7 @@ public void OnResultExecuted(ResultExecutedContext context)
if (!context.HttpContext.Response.HasStarted)
{
SaveTempData(context.Result, _factory, context.Filters, context.HttpContext);

var saveTempDataContext = GetTempDataContext(context.HttpContext);
if (saveTempDataContext != null)
{
saveTempDataContext.TempDataSaved = true;
}
GetTempDataContext(context.HttpContext)?.TempDataSaved = true;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,7 @@ public void OnResourceExecuting(ResourceExecutingContext context)
{
ArgumentNullException.ThrowIfNull(context);

var statusCodeFeature = context.HttpContext.Features.Get<IStatusCodePagesFeature>();
if (statusCodeFeature != null)
{
// Turn off the StatusCodePages feature.
statusCodeFeature.Enabled = false;
}
// Turn off the StatusCodePages feature.
context.HttpContext.Features.Get<IStatusCodePagesFeature>()?.Enabled = false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,7 @@ public async Task<bool> HandleRequestAsync()
Logger.Reauthenticating();
_negotiateState.Dispose();
_negotiateState = null;
if (persistence != null)
{
persistence.State = null;
}
persistence?.State = null;
}

_negotiateState ??= Options.StateFactory.CreateInstance();
Expand Down
5 changes: 1 addition & 4 deletions src/Servers/HttpSys/src/RequestProcessing/Request.cs
Original file line number Diff line number Diff line change
Expand Up @@ -264,10 +264,7 @@ public long? MaxRequestBodySize
set
{
EnsureRequestStream();
if (_nativeStream != null)
{
_nativeStream.MaxSize = value;
}
_nativeStream?.MaxSize = value;
}
}

Expand Down
5 changes: 1 addition & 4 deletions src/Servers/HttpSys/src/RequestProcessing/Response.cs
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,7 @@ public TimeSpan? CacheTtl
// callers if they try to add them too late. E.g. after Content-Length or CompleteAsync().
internal void MakeTrailersReadOnly()
{
if (_trailers != null)
{
_trailers.IsReadOnly = true;
}
_trailers?.IsReadOnly = true;
}

internal void Abort()
Expand Down
6 changes: 1 addition & 5 deletions src/Shared/HttpExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,6 @@ internal static void ClearEndpoint(HttpContext context)
context.SetEndpoint(endpoint: null);
}

var routeValuesFeature = context.Features.Get<IRouteValuesFeature>();
if (routeValuesFeature != null)
{
routeValuesFeature.RouteValues = null!;
}
context.Features.Get<IRouteValuesFeature>()?.RouteValues = null!;
}
}
5 changes: 1 addition & 4 deletions src/Tools/dotnet-user-jwts/src/Helpers/JwtStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@ public JwtStore(string userSecretsId, Program program = null)
Load();

// For testing.
if (program is not null)
{
program.UserJwtsFilePath = _filePath;
}
program?.UserJwtsFilePath = _filePath;
}

public IDictionary<string, Jwt> Jwts { get; private set; } = new Dictionary<string, Jwt>();
Expand Down
Loading