Nalix.Analyzers Code Fixes¶
Nalix.Analyzers.CodeFixes provides the Roslyn fixes that complement the diagnostics in Nalix.Analyzers.
Use this page when you want a quick sense of what the analyzer can usually fix for you automatically.
Source mapping¶
src/Nalix.Analyzers.CodeFixes/ConfigurationIgnoreCodeFixProvider.cssrc/Nalix.Analyzers.CodeFixes/DispatchLoopCountCodeFixProvider.cssrc/Nalix.Analyzers.CodeFixes/DuplicateSerializeOrderCodeFixProvider.cssrc/Nalix.Analyzers.CodeFixes/GenericPacketHandlerCodeFixProvider.cssrc/Nalix.Analyzers.CodeFixes/MiddlewareCodeFixProvider.cssrc/Nalix.Analyzers.CodeFixes/NullMiddlewareCodeFixProvider.cssrc/Nalix.Analyzers.CodeFixes/PacketControllerCodeFixProvider.cssrc/Nalix.Analyzers.CodeFixes/PacketDeserializeCodeFixProvider.cssrc/Nalix.Analyzers.CodeFixes/PacketOpcodeCodeFixProvider.cssrc/Nalix.Analyzers.CodeFixes/PacketRegistryDeserializerCodeFixProvider.cssrc/Nalix.Analyzers.CodeFixes/PacketSelfTypeCodeFixProvider.cssrc/Nalix.Analyzers.CodeFixes/RedundantPacketCastCodeFixProvider.cssrc/Nalix.Analyzers.CodeFixes/ResetForPoolCodeFixProvider.cssrc/Nalix.Analyzers.CodeFixes/RequestOptionsConsistencyCodeFixProvider.cssrc/Nalix.Analyzers.CodeFixes/SerializationConflictCodeFixProvider.cssrc/Nalix.Analyzers.CodeFixes/SerializeOrderMissingCodeFixProvider.cs
Main pieces¶
ConfigurationIgnoreCodeFixProviderDispatchLoopCountCodeFixProviderDuplicateSerializeOrderCodeFixProviderGenericPacketHandlerCodeFixProviderMiddlewareCodeFixProviderNullMiddlewareCodeFixProviderPacketControllerCodeFixProviderPacketDeserializeCodeFixProviderPacketOpcodeCodeFixProviderPacketRegistryDeserializerCodeFixProviderPacketSelfTypeCodeFixProviderRedundantPacketCastCodeFixProviderResetForPoolCodeFixProviderRequestOptionsConsistencyCodeFixProviderSerializationConflictCodeFixProviderSerializeOrderMissingCodeFixProvider
What the code fixes do¶
The available fixes currently cover these common workflows:
- add missing packet or controller attributes
- fix packet self-type inheritance or deserializer shape
- clamp invalid dispatch loop counts into supported range
- add missing
SerializeOrder - resolve
SerializeIgnoreversusSerializeOrderconflicts - add
ConfiguredIgnorefor unsupported configuration properties - add middleware attributes or ordering helpers
- remove redundant
PacketContext<T>.Packetcasts - resolve null middleware registrations
- add a missing registry deserializer pattern
- add a
base.ResetForPool()call in packet reset code - normalize inconsistent request retry/timeout option combinations
- remove
PacketOpcodeattributes from generic handlers
Common fix groups¶
Packet and controller fixes¶
PacketControllerCodeFixProviderPacketOpcodeCodeFixProviderPacketDeserializeCodeFixProviderPacketRegistryDeserializerCodeFixProviderPacketSelfTypeCodeFixProvider
Serialization fixes¶
SerializeOrderMissingCodeFixProviderDuplicateSerializeOrderCodeFixProviderSerializationConflictCodeFixProvider
Middleware and configuration fixes¶
MiddlewareCodeFixProviderNullMiddlewareCodeFixProviderDispatchLoopCountCodeFixProviderConfigurationIgnoreCodeFixProviderRequestOptionsConsistencyCodeFixProvider
Lifecycle fixes¶
ResetForPoolCodeFixProviderRedundantPacketCastCodeFixProviderGenericPacketHandlerCodeFixProvider
Practical notes¶
- Code fixes are intentionally narrow. They usually make the smallest safe correction, then let you refine the code afterward.
- Not every diagnostic has a code fix. Some are better left as human decisions, especially when the fix would be ambiguous.
- The code fixes are most helpful when you are already close to the intended Nalix shape.
Common pitfalls¶
- assuming every analyzer warning has an automatic fix
- applying a mechanical fix without checking whether the surrounding type design is correct
- using a code fix to patch over a larger architecture mismatch