diff --git a/src/Components/Components/src/ComponentFactory.cs b/src/Components/Components/src/ComponentFactory.cs index b515982a8d1d..71f23fc2c3c2 100644 --- a/src/Components/Components/src/ComponentFactory.cs +++ b/src/Components/Components/src/ComponentFactory.cs @@ -134,7 +134,26 @@ void Initialize(IServiceProvider serviceProvider, IComponent component) } // Tracks information about a specific component type that ComponentFactory uses - private record class ComponentTypeInfoCacheEntry( - IComponentRenderMode? ComponentTypeRenderMode, - Action PerformPropertyInjection); + private sealed class ComponentTypeInfoCacheEntry + { + public IComponentRenderMode? ComponentTypeRenderMode { get; } + + public Action PerformPropertyInjection { get; } + + public ComponentTypeInfoCacheEntry( + IComponentRenderMode? componentTypeRenderMode, + Action performPropertyInjection) + { + ComponentTypeRenderMode = componentTypeRenderMode; + PerformPropertyInjection = performPropertyInjection; + } + + public void Deconstruct( + out IComponentRenderMode? componentTypeRenderMode, + out Action performPropertyInjection) + { + componentTypeRenderMode = ComponentTypeRenderMode; + performPropertyInjection = PerformPropertyInjection; + } + } } diff --git a/src/Components/Endpoints/src/FormMapping/Factories/ComplexType/ComplexTypeExpressionConverterFactoryOfT.cs b/src/Components/Endpoints/src/FormMapping/Factories/ComplexType/ComplexTypeExpressionConverterFactoryOfT.cs index cbd72f640321..70e419a17aba 100644 --- a/src/Components/Endpoints/src/FormMapping/Factories/ComplexType/ComplexTypeExpressionConverterFactoryOfT.cs +++ b/src/Components/Endpoints/src/FormMapping/Factories/ComplexType/ComplexTypeExpressionConverterFactoryOfT.cs @@ -576,10 +576,44 @@ private static FormDataConverterReadParameters CreateFormDataConverterParameters Expression.Parameter(typeof(bool).MakeByRefType(), "foundValue")); } - private record struct FormDataConverterReadParameters( - ParameterExpression ReaderParam, - ParameterExpression TypeParam, - ParameterExpression OptionsParam, - ParameterExpression ResultParam, - ParameterExpression FoundValueParam); + private readonly struct FormDataConverterReadParameters + { + public ParameterExpression ReaderParam { get; } + + public ParameterExpression TypeParam { get; } + + public ParameterExpression OptionsParam { get; } + + public ParameterExpression ResultParam { get; } + + public ParameterExpression FoundValueParam { get; } + + public FormDataConverterReadParameters( + ParameterExpression readerParam, + ParameterExpression typeParam, + ParameterExpression optionsParam, + ParameterExpression resultParam, + ParameterExpression foundValueParam) + { + ReaderParam = readerParam; + TypeParam = typeParam; + OptionsParam = optionsParam; + ResultParam = resultParam; + FoundValueParam = foundValueParam; + } + + public void Deconstruct( + out ParameterExpression readerParam, + out ParameterExpression typeParam, + out ParameterExpression optionsParam, + out ParameterExpression resultParam, + out ParameterExpression foundValueParam) + { + readerParam = ReaderParam; + typeParam = TypeParam; + optionsParam = OptionsParam; + resultParam = ResultParam; + foundValueParam = FoundValueParam; + } + } } diff --git a/src/Components/Endpoints/src/Rendering/EndpointHtmlRenderer.Streaming.cs b/src/Components/Endpoints/src/Rendering/EndpointHtmlRenderer.Streaming.cs index 4316b745b691..393b4ab5cf0e 100644 --- a/src/Components/Endpoints/src/Rendering/EndpointHtmlRenderer.Streaming.cs +++ b/src/Components/Endpoints/src/Rendering/EndpointHtmlRenderer.Streaming.cs @@ -251,6 +251,29 @@ private void WriteComponentHtml(int componentId, TextWriter output, bool allowBo } } - private readonly record struct ComponentIdAndDepth(int ComponentId, int Depth); - private readonly record struct SequenceAndKey(int Sequence, object? Key); + private readonly struct ComponentIdAndDepth + { + public int ComponentId { get; } + + public int Depth { get; } + + public ComponentIdAndDepth(int componentId, int depth) + { + ComponentId = componentId; + Depth = depth; + } + } + + private readonly struct SequenceAndKey + { + public int Sequence { get; } + + public object? Key { get; } + + public SequenceAndKey(int sequence, object? key) + { + Sequence = sequence; + Key = key; + } + } } diff --git a/src/Components/Shared/src/ExpressionFormatting/ExpressionFormatter.cs b/src/Components/Shared/src/ExpressionFormatting/ExpressionFormatter.cs index c8e4756e620d..38243e07f660 100644 --- a/src/Components/Shared/src/ExpressionFormatting/ExpressionFormatter.cs +++ b/src/Components/Shared/src/ExpressionFormatting/ExpressionFormatter.cs @@ -160,7 +160,7 @@ static MethodInfoData GetMethodInfoData(MethodInfo methodInfo) var declaringType = methodInfo.DeclaringType; if (declaringType is null) { - return new(IsSingleArgumentIndexer: false); + return new(isSingleArgumentIndexer: false); } // Check whether GetDefaultMembers() (if present in CoreCLR) would return a member of this type. Compiler @@ -168,14 +168,14 @@ static MethodInfoData GetMethodInfoData(MethodInfo methodInfo) var defaultMember = declaringType.GetCustomAttribute(inherit: true); if (defaultMember is null) { - return new(IsSingleArgumentIndexer: false); + return new(isSingleArgumentIndexer: false); } // Find default property (the indexer) and confirm its getter is the method in this expression. var runtimeProperties = declaringType.GetRuntimeProperties(); if (runtimeProperties is null) { - return new(IsSingleArgumentIndexer: false); + return new(isSingleArgumentIndexer: false); } foreach (var property in runtimeProperties) @@ -183,11 +183,11 @@ static MethodInfoData GetMethodInfoData(MethodInfo methodInfo) if (string.Equals(defaultMember.MemberName, property.Name, StringComparison.Ordinal) && property.GetMethod == methodInfo) { - return new(IsSingleArgumentIndexer: true); + return new(isSingleArgumentIndexer: true); } } - return new(IsSingleArgumentIndexer: false); + return new(isSingleArgumentIndexer: false); } } @@ -297,5 +297,13 @@ private static void FormatConstantValue(ConstantExpression constantExpression, r } } - private record struct MethodInfoData(bool IsSingleArgumentIndexer); + private readonly struct MethodInfoData + { + public bool IsSingleArgumentIndexer { get; } + + public MethodInfoData(bool isSingleArgumentIndexer) + { + IsSingleArgumentIndexer = isSingleArgumentIndexer; + } + } } diff --git a/src/Components/WebAssembly/Server/src/TargetPickerUi.cs b/src/Components/WebAssembly/Server/src/TargetPickerUi.cs index a6af3fdebca7..7ec8a74362e8 100644 --- a/src/Components/WebAssembly/Server/src/TargetPickerUi.cs +++ b/src/Components/WebAssembly/Server/src/TargetPickerUi.cs @@ -425,13 +425,29 @@ private async Task> GetOpenedBrowserTabs() return JsonSerializer.Deserialize(jsonResponse, JsonOptions)!; } - private sealed record BrowserTab - ( - string Id, - string Type, - string Url, - string Title, - string DevtoolsFrontendUrl, - string WebSocketDebuggerUrl - ); + private sealed class BrowserTab + { + public string Id { get; } + public string Type { get; } + public string Url { get; } + public string Title { get; } + public string DevtoolsFrontendUrl { get; } + public string WebSocketDebuggerUrl { get; } + + public BrowserTab( + string id, + string type, + string url, + string title, + string devtoolsFrontendUrl, + string webSocketDebuggerUrl) + { + Id = id; + Type = type; + Url = url; + Title = title; + DevtoolsFrontendUrl = devtoolsFrontendUrl; + WebSocketDebuggerUrl = webSocketDebuggerUrl; + } + } } diff --git a/src/Components/WebAssembly/WebAssembly.Authentication/src/Models/InteractiveRequestOptions.cs b/src/Components/WebAssembly/WebAssembly.Authentication/src/Models/InteractiveRequestOptions.cs index 6c37dda34a62..45a3ede31768 100644 --- a/src/Components/WebAssembly/WebAssembly.Authentication/src/Models/InteractiveRequestOptions.cs +++ b/src/Components/WebAssembly/WebAssembly.Authentication/src/Models/InteractiveRequestOptions.cs @@ -115,11 +115,32 @@ public override void Write(Utf8JsonWriter writer, InteractiveRequestOptions valu InteractiveRequestOptionsSerializerContext.Default.OptionsRecord); } - internal record struct OptionsRecord( - [property: JsonInclude] string ReturnUrl, - [property: JsonInclude] IEnumerable Scopes, - [property: JsonInclude] InteractionType Interaction, - [property: JsonInclude] Dictionary? AdditionalRequestParameters); + internal readonly struct OptionsRecord + { + [JsonInclude] + public string ReturnUrl { get; init; } + + [JsonInclude] + public IEnumerable Scopes { get; init; } + + [JsonInclude] + public InteractionType Interaction { get; init; } + + [JsonInclude] + public Dictionary? AdditionalRequestParameters { get; init; } + + public OptionsRecord( + string returnUrl, + IEnumerable scopes, + InteractionType interaction, + Dictionary? additionalRequestParameters) + { + ReturnUrl = returnUrl; + Scopes = scopes; + Interaction = interaction; + AdditionalRequestParameters = additionalRequestParameters; + } + } } } diff --git a/src/Components/WebAssembly/WebAssembly.Authentication/src/Services/RemoteAuthenticationService.cs b/src/Components/WebAssembly/WebAssembly.Authentication/src/Services/RemoteAuthenticationService.cs index ce27eabf5960..62d9fa5265e4 100644 --- a/src/Components/WebAssembly/WebAssembly.Authentication/src/Services/RemoteAuthenticationService.cs +++ b/src/Components/WebAssembly/WebAssembly.Authentication/src/Services/RemoteAuthenticationService.cs @@ -255,4 +255,16 @@ internal class RemoteAuthenticationServiceJavaScriptLoggingOptions } // Internal for testing purposes -internal record struct InternalAccessTokenResult([property: JsonConverter(typeof(JsonStringEnumConverter))] AccessTokenResultStatus Status, AccessToken Token); +internal readonly struct InternalAccessTokenResult +{ + [JsonConverter(typeof(JsonStringEnumConverter))] + public AccessTokenResultStatus Status { get; init; } + + public AccessToken Token { get; init; } + + public InternalAccessTokenResult(AccessTokenResultStatus status, AccessToken token) + { + Status = status; + Token = token; + } +} diff --git a/src/Components/WebView/WebView/src/Services/WebViewRenderer.cs b/src/Components/WebView/WebView/src/Services/WebViewRenderer.cs index 1284df8ebd74..b323ed1f39b6 100644 --- a/src/Components/WebView/WebView/src/Services/WebViewRenderer.cs +++ b/src/Components/WebView/WebView/src/Services/WebViewRenderer.cs @@ -78,9 +78,10 @@ public void NotifyRenderCompleted(long batchId) nextUnacknowledgedBatch.CompletionSource.SetResult(); } - private sealed record UnacknowledgedRenderBatch + private sealed class UnacknowledgedRenderBatch { public long BatchId { get; init; } + public TaskCompletionSource CompletionSource { get; init; } } } diff --git a/src/Grpc/JsonTranscoding/src/Shared/ServiceDescriptorHelpers.cs b/src/Grpc/JsonTranscoding/src/Shared/ServiceDescriptorHelpers.cs index ab7c9b161057..1af8db373119 100644 --- a/src/Grpc/JsonTranscoding/src/Shared/ServiceDescriptorHelpers.cs +++ b/src/Grpc/JsonTranscoding/src/Shared/ServiceDescriptorHelpers.cs @@ -428,11 +428,11 @@ public static Dictionary ResolveRouteParameterDescriptor { // A repeating field isn't a message type. The JSON parser will parse using the containing // type to get the repeating collection. - return new BodyDescriptorInfo(responseBodyDescriptor.ContainingType, responseBodyDescriptor, IsDescriptorRepeated: true, propertyInfo); + return new BodyDescriptorInfo(responseBodyDescriptor.ContainingType, responseBodyDescriptor, isDescriptorRepeated: true, propertyInfo); } else { - return new BodyDescriptorInfo(responseBodyDescriptor.MessageType, responseBodyDescriptor, IsDescriptorRepeated: false, propertyInfo); + return new BodyDescriptorInfo(responseBodyDescriptor.MessageType, responseBodyDescriptor, isDescriptorRepeated: false, propertyInfo); } } else @@ -444,7 +444,7 @@ public static Dictionary ResolveRouteParameterDescriptor requestParameter = methodInfo.GetParameters().SingleOrDefault(p => p.Name == "request"); } - return new BodyDescriptorInfo(methodDescriptor.InputType, FieldDescriptor: null, IsDescriptorRepeated: false, ParameterInfo: requestParameter); + return new BodyDescriptorInfo(methodDescriptor.InputType, fieldDescriptor: null, isDescriptorRepeated: false, parameterInfo: requestParameter); } } @@ -562,12 +562,32 @@ private static bool IsCustomType(MessageDescriptor messageDescriptor) return false; } - public sealed record BodyDescriptorInfo( - MessageDescriptor Descriptor, - FieldDescriptor? FieldDescriptor, - bool IsDescriptorRepeated, - PropertyInfo? PropertyInfo = null, - ParameterInfo? ParameterInfo = null); + public sealed class BodyDescriptorInfo + { + public MessageDescriptor Descriptor { get; } + + public FieldDescriptor? FieldDescriptor { get; } + + public bool IsDescriptorRepeated { get; } + + public PropertyInfo? PropertyInfo { get; } + + public ParameterInfo? ParameterInfo { get; } + + public BodyDescriptorInfo( + MessageDescriptor descriptor, + FieldDescriptor? fieldDescriptor, + bool isDescriptorRepeated, + PropertyInfo? propertyInfo = null, + ParameterInfo? parameterInfo = null) + { + Descriptor = descriptor; + FieldDescriptor = fieldDescriptor; + IsDescriptorRepeated = isDescriptorRepeated; + PropertyInfo = propertyInfo; + ParameterInfo = parameterInfo; + } + } public static string FormatUnderscoreName(string input, bool pascalCase, bool preservePeriod) { @@ -626,7 +646,21 @@ public static string FormatUnderscoreName(string input, bool pascalCase, bool pr } } -internal record RouteParameter( - List DescriptorsPath, - HttpRouteVariable RouteVariable, - string JsonPath); +internal sealed class RouteParameter +{ + public List DescriptorsPath { get; } + + public HttpRouteVariable RouteVariable { get; } + + public string JsonPath { get; } + + public RouteParameter( + List descriptorsPath, + HttpRouteVariable routeVariable, + string jsonPath) + { + DescriptorsPath = descriptorsPath; + RouteVariable = routeVariable; + JsonPath = jsonPath; + } +} diff --git a/src/Http/Routing/src/Matching/DfaMatcherBuilder.cs b/src/Http/Routing/src/Matching/DfaMatcherBuilder.cs index ed9844917e3f..f7e3adb6a8ca 100644 --- a/src/Http/Routing/src/Matching/DfaMatcherBuilder.cs +++ b/src/Http/Routing/src/Matching/DfaMatcherBuilder.cs @@ -987,5 +987,26 @@ private static bool TryGetRequiredValue(RoutePattern routePattern, RoutePatternP return !RouteValueEqualityComparer.Default.Equals(value, string.Empty); } - private readonly record struct DfaBuilderWorkerWorkItem(RouteEndpoint Endpoint, int PrecedenceDigit, List Parents); + public readonly struct DfaBuilderWorkerWorkItem + { + public RouteEndpoint Endpoint { get; } + + public int PrecedenceDigit { get; } + + public List Parents { get; } + + public DfaBuilderWorkerWorkItem(RouteEndpoint endpoint, int precedenceDigit, List parents) + { + Endpoint = endpoint; + PrecedenceDigit = precedenceDigit; + Parents = parents; + } + + public void Deconstruct(out RouteEndpoint endpoint, out int precedenceDigit, out List parents) + { + endpoint = Endpoint; + precedenceDigit = PrecedenceDigit; + parents = Parents; + } + } } diff --git a/src/Mvc/Mvc.Core/src/ModelBinding/Binders/CollectionModelBinder.cs b/src/Mvc/Mvc.Core/src/ModelBinding/Binders/CollectionModelBinder.cs index a20b50853db7..ebf4d17d3383 100644 --- a/src/Mvc/Mvc.Core/src/ModelBinding/Binders/CollectionModelBinder.cs +++ b/src/Mvc/Mvc.Core/src/ModelBinding/Binders/CollectionModelBinder.cs @@ -409,9 +409,16 @@ internal async Task BindComplexCollectionFromIndexes( } // Internal for testing. - internal sealed record CollectionResult(IEnumerable Model) + internal sealed class CollectionResult { + public IEnumerable Model { get; } + public IValidationStrategy? ValidationStrategy { get; init; } + + public CollectionResult(IEnumerable model) + { + Model = model; + } } /// diff --git a/src/Servers/Kestrel/Core/src/Internal/Infrastructure/HttpUtilities.cs b/src/Servers/Kestrel/Core/src/Internal/Infrastructure/HttpUtilities.cs index 3fa594841221..2feafb9834e2 100644 --- a/src/Servers/Kestrel/Core/src/Internal/Infrastructure/HttpUtilities.cs +++ b/src/Servers/Kestrel/Core/src/Internal/Infrastructure/HttpUtilities.cs @@ -605,4 +605,15 @@ private static bool IsHex(char ch) } } -internal sealed record AltSvcHeader(string Value, byte[] RawBytes); +internal sealed class AltSvcHeader +{ + public string Value { get; } + + public byte[] RawBytes { get; } + + public AltSvcHeader(string value, byte[] rawBytes) + { + Value = value; + RawBytes = rawBytes; + } +} diff --git a/src/Servers/Kestrel/Transport.Quic/src/Internal/QuicStreamContext.FeatureCollection.cs b/src/Servers/Kestrel/Transport.Quic/src/Internal/QuicStreamContext.FeatureCollection.cs index 057ae8464e11..48e0095110d7 100644 --- a/src/Servers/Kestrel/Transport.Quic/src/Internal/QuicStreamContext.FeatureCollection.cs +++ b/src/Servers/Kestrel/Transport.Quic/src/Internal/QuicStreamContext.FeatureCollection.cs @@ -15,7 +15,18 @@ internal sealed partial class QuicStreamContext : IStreamAbortFeature, IStreamClosedFeature { - private readonly record struct OnCloseRegistration(Action Callback, object? State); + private readonly struct OnCloseRegistration + { + public Action Callback { get; } + + public object? State { get; } + + public OnCloseRegistration(Action callback, object? state) + { + Callback = callback; + State = state; + } + } private IDictionary? _persistentState; private long? _error; diff --git a/src/Servers/Kestrel/shared/KnownHeaders.cs b/src/Servers/Kestrel/shared/KnownHeaders.cs index a9ecc50814ca..955aa482da3b 100644 --- a/src/Servers/Kestrel/shared/KnownHeaders.cs +++ b/src/Servers/Kestrel/shared/KnownHeaders.cs @@ -40,23 +40,37 @@ public class KnownHeaders .Select(h => h.Name) .ToArray(); - // These headers are excluded from generated IHeadersDictionary implementaiton. + // These headers are excluded from generated IHeadersDictionary implementation. public static readonly string[] NonPublicHeaderNames = new[] { HeaderNames.DNT, InternalHeaderNames.AltUsed }; - public record InternalHeader(string Identifier, string Name, bool IsPseudoHeader = false); + public sealed class InternalHeader + { + public string Identifier { get; } + + public string Name { get; } + + public bool IsPseudoHeader { get; } + + public InternalHeader(string identifier, string name, bool isPseudoHeader = false) + { + Identifier = identifier; + Name = name; + IsPseudoHeader = isPseudoHeader; + } + } public static readonly InternalHeader[] FormattedInternalHeaderNames = new[] { - new InternalHeader("Authority", InternalHeaderNames.Authority, IsPseudoHeader: true), - new InternalHeader("Method", InternalHeaderNames.Method, IsPseudoHeader: true), - new InternalHeader("Path", InternalHeaderNames.Path, IsPseudoHeader: true), - new InternalHeader("Scheme", InternalHeaderNames.Scheme, IsPseudoHeader: true), - new InternalHeader("Status", InternalHeaderNames.Status, IsPseudoHeader: true), - new InternalHeader("Protocol", InternalHeaderNames.Protocol, IsPseudoHeader: true), + new InternalHeader("Authority", InternalHeaderNames.Authority, isPseudoHeader: true), + new InternalHeader("Method", InternalHeaderNames.Method, isPseudoHeader: true), + new InternalHeader("Path", InternalHeaderNames.Path, isPseudoHeader: true), + new InternalHeader("Scheme", InternalHeaderNames.Scheme, isPseudoHeader: true), + new InternalHeader("Status", InternalHeaderNames.Status, isPseudoHeader: true), + new InternalHeader("Protocol", InternalHeaderNames.Protocol, isPseudoHeader: true), new InternalHeader("AltUsed", InternalHeaderNames.AltUsed) }; diff --git a/src/Shared/BrowserTesting/src/BrowserManagerConfiguration.cs b/src/Shared/BrowserTesting/src/BrowserManagerConfiguration.cs index 613639d0c582..d33a172ed4cf 100644 --- a/src/Shared/BrowserTesting/src/BrowserManagerConfiguration.cs +++ b/src/Shared/BrowserTesting/src/BrowserManagerConfiguration.cs @@ -1,10 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; using Microsoft.Extensions.Configuration; using Microsoft.Playwright; @@ -354,4 +350,18 @@ private static BrowserTypeLaunchOptions Combine(BrowserTypeLaunchOptions default }; } -public record BrowserOptions(BrowserKind BrowserKind, BrowserTypeLaunchOptions BrowserLaunchOptions, BrowserNewContextOptions DefaultContextOptions); +public sealed class BrowserOptions +{ + public BrowserKind BrowserKind { get; } + + public BrowserTypeLaunchOptions BrowserLaunchOptions { get; } + + public BrowserNewContextOptions DefaultContextOptions { get; } + + public BrowserOptions(BrowserKind browserKind, BrowserTypeLaunchOptions browserLaunchOptions, BrowserNewContextOptions defaultContextOptions) + { + BrowserKind = browserKind; + BrowserLaunchOptions = browserLaunchOptions; + DefaultContextOptions = defaultContextOptions; + } +} diff --git a/src/Shared/BrowserTesting/src/PageInformation.cs b/src/Shared/BrowserTesting/src/PageInformation.cs index b993dd92d29e..19bc7b3af652 100644 --- a/src/Shared/BrowserTesting/src/PageInformation.cs +++ b/src/Shared/BrowserTesting/src/PageInformation.cs @@ -1,9 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; -using System.Collections.Generic; -using System.Threading.Tasks; using Microsoft.Extensions.Logging; using Microsoft.Playwright; @@ -116,5 +113,16 @@ private void RecordConsoleMessage(object sender, IConsoleMessage message) } } - public record LogEntry(string Message, string Level); + public sealed class LogEntry + { + public string Message { get; } + + public string Level { get; } + + public LogEntry(string message, string level) + { + Message = message; + Level = level; + } + } }