aspnetcore icon indicating copy to clipboard operation
aspnetcore copied to clipboard

Reduce record usage in published aspnetcore projects

Open JamesNK opened this issue 2 years ago • 1 comments

records have a slim syntax and provide many features, but they also generate a lot of code. And much of that code can't be trimmed. A record can bloat app publish size.

See https://github.com/dotnet/aspnetcore/pull/45604#discussion_r1061055000 for an example.

  • [ ] Audit published aspnetcore projects for record usage. records in test projects is fine.
  • [ ] See if there is an analyzer that we can enable to warn about record use, and enable.

JamesNK avatar Jan 04 '23 06:01 JamesNK

@eerhardt Part of publish size effort.

JamesNK avatar Jan 04 '23 06:01 JamesNK

Thanks for contacting us.

We're moving this issue to the .NET 8 Planning milestone for future evaluation / consideration. We would like to keep this around to collect more feedback, which can help us with prioritizing this work. We will re-evaluate this issue, during our next planning meeting(s). If we later determine, that the issue has no community involvement, or it's very rare and low-impact issue, we will close it - so that the team can focus on more important and high impact issues. To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.

ghost avatar Jan 05 '23 19:01 ghost

Those are all places where record is used in our repo, not including tests and analyzers.

MVC.Core https://github.com/dotnet/aspnetcore/blob/493407b5a2783a7dbae18e43a04b6a5513a9ece5/src/Mvc/Mvc.Core/src/ModelBinding/Binders/CollectionModelBinder.cs#L405

Kestrel https://github.com/dotnet/aspnetcore/blob/493407b5a2783a7dbae18e43a04b6a5513a9ece5/src/Servers/Kestrel/Core/src/Internal/Infrastructure/HttpUtilities.cs#L601 https://github.com/dotnet/aspnetcore/blob/493407b5a2783a7dbae18e43a04b6a5513a9ece5/src/Servers/Kestrel/shared/KnownHeaders.cs#L50 https://github.com/dotnet/aspnetcore/blob/493407b5a2783a7dbae18e43a04b6a5513a9ece5/src/Servers/Kestrel/Transport.Quic/src/Internal/QuicStreamContext.FeatureCollection.cs#L18

Routing https://github.com/dotnet/aspnetcore/blob/493407b5a2783a7dbae18e43a04b6a5513a9ece5/src/Http/Routing/src/Matching/DfaMatcherBuilder.cs#L943

Components https://github.com/dotnet/aspnetcore/blob/493407b5a2783a7dbae18e43a04b6a5513a9ece5/src/Components/WebAssembly/WebAssembly.Authentication/src/Services/RemoteAuthenticationService.cs#L258 https://github.com/dotnet/aspnetcore/blob/493407b5a2783a7dbae18e43a04b6a5513a9ece5/src/Components/WebView/WebView/src/Services/WebViewRenderer.cs#L79 https://github.com/dotnet/aspnetcore/blob/493407b5a2783a7dbae18e43a04b6a5513a9ece5/src/Components/WebAssembly/WebAssembly.Authentication/src/Models/InteractiveRequestOptions.cs#L118

Grpc https://github.com/dotnet/aspnetcore/blob/493407b5a2783a7dbae18e43a04b6a5513a9ece5/src/Grpc/JsonTranscoding/src/Shared/ServiceDescriptorHelpers.cs#L447 https://github.com/dotnet/aspnetcore/blob/493407b5a2783a7dbae18e43a04b6a5513a9ece5/src/Grpc/JsonTranscoding/src/Shared/ServiceDescriptorHelpers.cs#L511

Shared (Probably used in tests) https://github.com/dotnet/aspnetcore/blob/493407b5a2783a7dbae18e43a04b6a5513a9ece5/src/Shared/BrowserTesting/src/BrowserManagerConfiguration.cs#L357 https://github.com/dotnet/aspnetcore/blob/493407b5a2783a7dbae18e43a04b6a5513a9ece5/src/Shared/BrowserTesting/src/PageInformation.cs#L119

brunolins16 avatar Jan 24 '23 21:01 brunolins16

@eerhardt @captainsafia where do you think this sits in terms of priority right now. I think the work is still valid, but perhaps a lower priority for now?

mitchdenny avatar May 24 '23 22:05 mitchdenny

Yeah, it's pretty low on the priority list IMO. The only case that I would think is high priority is to ensure we don't ship any "new" public record types in .NET 8. If there are ones we added in 8, making them normal classes would be important.

eerhardt avatar May 24 '23 23:05 eerhardt

would we take community changes for it - should it be 'help wanted' - or not a good candidate?

danmoseley avatar May 24 '23 23:05 danmoseley

Agree that this is a good candidate for help wanted!

I've gone ahead and updated @brunolins16's comment to reflect the the fact that records were removed from RDG so the listi s more accurate for contributors.

captainsafia avatar May 25 '23 16:05 captainsafia

Here are some other record types that I found in the project (excluding those in analyzer, test, and tools code):

Microsoft.AspNetCore.Components

https://github.com/dotnet/aspnetcore/blob/e1f66845c0c65b7ed8413cf75656762dd2698f40/src/Components/Components/src/ComponentFactory.cs#L123-L125

https://github.com/dotnet/aspnetcore/blob/e1f66845c0c65b7ed8413cf75656762dd2698f40/src/Components/Endpoints/src/Binding/Factories/ComplexType/ComplexTypeExpressionConverterFactoryOfT.cs#L159-L164

https://github.com/dotnet/aspnetcore/blob/da8a6f0766d1f333cc2faec72f97751e3c605dac/src/Components/Endpoints/src/Rendering/EndpointHtmlRenderer.cs#L251

https://github.com/dotnet/aspnetcore/blob/e1f66845c0c65b7ed8413cf75656762dd2698f40/src/Components/Endpoints/src/Rendering/EndpointHtmlRenderer.Streaming.cs#L248-L248

https://github.com/dotnet/aspnetcore/blob/e1f66845c0c65b7ed8413cf75656762dd2698f40/src/Components/Web/src/Forms/ExpressionFormatting/ExpressionFormatter.cs#L266

https://github.com/dotnet/aspnetcore/blob/e1f66845c0c65b7ed8413cf75656762dd2698f40/src/Components/WebAssembly/Server/src/TargetPickerUi.cs#L428-L436

david-acker avatar Jun 22 '23 01:06 david-acker