Add missing value types to EfAnalysisConstants#17
Add missing value types to EfAnalysisConstants#17HandyS11 merged 2 commits intorefacto/ImproveCodeQualityfrom
Conversation
Co-authored-by: HandyS11 <62420910+HandyS11@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR addresses incomplete type detection in Entity Framework analysis by adding missing .NET value types to EfAnalysisConstants. The change ensures that IsEfValueType() correctly identifies all common .NET value types when semantic analysis is unavailable.
Changes:
- Added constant definitions for byte, sbyte, ushort, uint, ulong, and char types
- Extended the
ValueTypesHashSet to include these newly defined constants
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| public const string Long = "long"; | ||
| public const string Single = "Single"; | ||
| public const string Short = "short"; | ||
| public const string Byte = "byte"; |
There was a problem hiding this comment.
Missing .NET type name constant for Byte. Following the existing pattern (e.g., Int and Int32, Bool and Boolean), there should be a constant named Byte with value "Byte" to represent the .NET BCL type name, in addition to the lowercase byte keyword alias.
| public const string Single = "Single"; | ||
| public const string Short = "short"; | ||
| public const string Byte = "byte"; | ||
| public const string SByte = "sbyte"; |
There was a problem hiding this comment.
Missing .NET type name constant for SByte. Following the existing pattern (e.g., Int and Int32, Bool and Boolean), there should be a constant named SByte with value "SByte" to represent the .NET BCL type name, in addition to the lowercase sbyte keyword alias. This is necessary for proper type detection when the type is referenced by its .NET name.
| public const string Short = "short"; | ||
| public const string Byte = "byte"; | ||
| public const string SByte = "sbyte"; | ||
| public const string UShort = "ushort"; |
There was a problem hiding this comment.
Missing UInt16 constant for the .NET BCL type name. The unsigned short type has the .NET name UInt16, not UShort. Following the existing pattern (e.g., Long/Int64, UInt/UInt32), there should be both UShort with value "ushort" (the C# keyword) and UInt16 with value "UInt16" (the .NET type name).
| public const string UInt32 = "UInt32"; | ||
| public const string ULong = "ulong"; | ||
| public const string UInt64 = "UInt64"; | ||
| public const string Char = "char"; |
There was a problem hiding this comment.
Missing .NET type name constant for Char. Following the existing pattern (e.g., Int and Int32, Bool and Boolean), there should be a constant named Char with value "Char" to represent the .NET BCL type name, in addition to the lowercase char keyword alias.
| Byte, | ||
| SByte, | ||
| UShort, | ||
| UInt, | ||
| UInt32, | ||
| ULong, | ||
| UInt64, | ||
| Char |
There was a problem hiding this comment.
The ValueTypes HashSet is missing the .NET BCL type name equivalents for the newly added types. Following the existing pattern where both C# keyword aliases and .NET type names are included (e.g., Int and Int32, Bool and Boolean), the following should be added after defining the missing constants: a reference to Byte (for "Byte"), a reference to SByte (for "SByte"), a reference to UInt16 (for "UInt16"), and a reference to Char (for "Char"). This ensures proper type detection regardless of whether the type is referenced using the C# keyword or the .NET type name.
The
ValueTypesHashSet was missing common .NET value types (byte, sbyte, ushort, uint, ulong, char), causing incomplete type detection when semantic analysis is unavailable.Changes:
byte,uint) and .NET type names (Byte,UInt32) following existing patternsValueTypesHashSet with all missing typesThis ensures
IsEfValueType()correctly identifies all .NET value types used in Entity Framework models.💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.