Просмотр исходного кода

Update .NET SDK to 10.0.100-preview.4.25180.3 (#61244)

* Update .NET SDK

Update .NET SDK to version 10.0.100-preview.4.25180.3.

---
updated-dependencies:
- dependency-name: Microsoft.NET.Sdk
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

* Fix IDE0031 warnings

* Fix more IDE0031 warnings

---------

Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Stephen Halter <[email protected]>
github-actions[bot] 11 месяцев назад
Родитель
Сommit
72fd6dde3c

+ 2 - 2
global.json

@@ -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)"

+ 1 - 4
src/Components/Server/src/Circuits/CircuitHost.cs

@@ -828,10 +828,7 @@ internal partial class CircuitHost : IAsyncDisposable
                             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.

+ 3 - 12
src/Hosting/Hosting/src/Http/DefaultHttpContextFactory.cs

@@ -58,10 +58,7 @@ public class DefaultHttpContextFactory : IHttpContextFactory
 
         httpContext.Initialize(featureCollection);
 
-        if (_httpContextAccessor != null)
-        {
-            _httpContextAccessor.HttpContext = httpContext;
-        }
+        _httpContextAccessor?.HttpContext = httpContext;
 
         httpContext.FormOptions = _formOptions;
         httpContext.ServiceScopeFactory = _serviceScopeFactory;
@@ -72,18 +69,12 @@ public class DefaultHttpContextFactory : IHttpContextFactory
     /// </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();
     }

+ 2 - 6
src/Http/Http/src/HttpContextAccessor.cs

@@ -22,12 +22,8 @@ public class HttpContextAccessor : IHttpContextAccessor
         }
         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)
             {

+ 1 - 5
src/Middleware/Rewrite/src/RewriteMiddleware.cs

@@ -77,11 +77,7 @@ public class RewriteMiddleware
                 // 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);
             }
         }

+ 2 - 5
src/Middleware/Rewrite/src/UrlActions/CustomResponseAction.cs

@@ -31,11 +31,8 @@ internal sealed class CustomResponseAction : UrlAction
 
         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";

+ 1 - 5
src/Middleware/StaticFiles/src/StaticFileContext.cs

@@ -407,11 +407,7 @@ internal struct StaticFileContext
     // 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

+ 1 - 6
src/Mvc/Mvc.Core/src/ModelBinding/Validation/ValidationVisitor.cs

@@ -248,12 +248,7 @@ public class ValidationVisitor
         {
             // 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;
         }
     }

+ 2 - 11
src/Mvc/Mvc.ViewFeatures/src/Filters/SaveTempDataFilter.cs

@@ -83,11 +83,7 @@ internal sealed class SaveTempDataFilter : IResourceFilter, IResultFilter
         // 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;
         }
     }
 
@@ -105,12 +101,7 @@ internal sealed class SaveTempDataFilter : IResourceFilter, IResultFilter
         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;
         }
     }
 

+ 2 - 6
src/Mvc/Mvc.ViewFeatures/src/SkipStatusCodePagesAttribute.cs

@@ -23,11 +23,7 @@ public class SkipStatusCodePagesAttribute : Attribute, IResourceFilter, ISkipSta
     {
         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;
     }
 }

+ 1 - 4
src/Security/Authentication/Negotiate/src/NegotiateHandler.cs

@@ -126,10 +126,7 @@ public class NegotiateHandler : AuthenticationHandler<NegotiateOptions>, IAuthen
                 Logger.Reauthenticating();
                 _negotiateState.Dispose();
                 _negotiateState = null;
-                if (persistence != null)
-                {
-                    persistence.State = null;
-                }
+                persistence?.State = null;
             }
 
             _negotiateState ??= Options.StateFactory.CreateInstance();

+ 1 - 4
src/Servers/HttpSys/src/RequestProcessing/Request.cs

@@ -264,10 +264,7 @@ internal sealed partial class Request
         set
         {
             EnsureRequestStream();
-            if (_nativeStream != null)
-            {
-                _nativeStream.MaxSize = value;
-            }
+            _nativeStream?.MaxSize = value;
         }
     }
 

+ 1 - 4
src/Servers/HttpSys/src/RequestProcessing/Response.cs

@@ -186,10 +186,7 @@ internal sealed class Response
     // 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()

+ 1 - 5
src/Shared/HttpExtensions.cs

@@ -58,10 +58,6 @@ internal static class HttpExtensions
             context.SetEndpoint(endpoint: null);
         }
 
-        var routeValuesFeature = context.Features.Get<IRouteValuesFeature>();
-        if (routeValuesFeature != null)
-        {
-            routeValuesFeature.RouteValues = null!;
-        }
+        context.Features.Get<IRouteValuesFeature>()?.RouteValues = null!;
     }
 }

+ 1 - 4
src/Tools/dotnet-user-jwts/src/Helpers/JwtStore.cs

@@ -18,10 +18,7 @@ public class JwtStore
         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>();