Unexpected Reverse Engineering for Bit Field
See original GitHub issueDescribe what is not working as expected.
Given the SQL Server table
USE [CuratedPhase1]
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
CREATE TABLE [dbo].[FanProductPerformanceCorrections](
[FanProductId] [uniqueidentifier] NOT NULL,
[FanPerformanceCorrectionId] [uniqueidentifier] NOT NULL,
[CorrectionOrder] [smallint] NOT NULL,
[MustHave] [bit] NOT NULL,
[ApplyCorrection] [bit] NOT NULL,
CONSTRAINT [PK_FanProductPerformanceCorrections] PRIMARY KEY CLUSTERED
(
[FanProductId] ASC,
[FanPerformanceCorrectionId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
)
GO
Expect the following reverse engineering result
public partial class FanProductPerformanceCorrection
{
public FanProductPerformanceCorrection()
{
FanProductPerformanceCorrectionVariables = new HashSet<FanProductPerformanceCorrectionVariable>();
}
public Guid FanProductId { get; set; }
public Guid FanPerformanceCorrectionId { get; set; }
public short CorrectionOrder { get; set; }
public bool MustHave { get; set; }
public bool ApplyCorrection { get; set; }
public virtual FanPerformanceCorrection FanPerformanceCorrection { get; set; }
public virtual FanProduct FanProduct { get; set; }
public virtual ICollection<FanProductPerformanceCorrectionVariable> FanProductPerformanceCorrectionVariables { get; set; }
}
but getting
public partial class FanProductPerformanceCorrection
{
public FanProductPerformanceCorrection()
{
FanProductPerformanceCorrectionVariables = new HashSet<FanProductPerformanceCorrectionVariable>();
}
public Guid FanProductId { get; set; }
public Guid FanPerformanceCorrectionId { get; set; }
public short CorrectionOrder { get; set; }
public bool MustHave { get; set; }
public bool? ApplyCorrection { get; set; }
public virtual FanPerformanceCorrection FanPerformanceCorrection { get; set; }
public virtual FanProduct FanProduct { get; set; }
public virtual ICollection<FanProductPerformanceCorrectionVariable> FanProductPerformanceCorrectionVariables { get; set; }
}
Note that APPLYCORRECTION in the second C# example is marked as nullable (bool?).
This behavior has been present for at least the last six months, and is not specific to recent builds. (we’ve been fixing it by hand)
Issue Analytics
- State:
- Created 4 years ago
- Comments:11 (7 by maintainers)
Top Results From Across the Web
Reverse Engineering: Binary Security
Any reverse engineer could pop open IDA pro, disassemble the program, spectate and understand how the program works through static and dynamic ...
Read more >Protecting executable from reverse engineering?
And do consider that by far the best way to avoid people reverse-engineering your code is to make it useless so that they...
Read more >Reverse-engineering IR check bits/CRC
Reverse-engineering IR check bits/CRC · 32 bit packet spanning multiple individual values/commands of varying length (plus 1 start bit/preamble, ...
Read more >Is there a way to name a flag for a bit field in Ghidra?
select SCALAR in decompiler window right click ->Set Equate ("E" short cut) type or select if available. a sample EQUATE as below
Read more >F(PGA) Tour : Evading reverse engineering
When reverse engineering an FPGA bitfile, the engineer must reverse engineer the entire bitfile. Each bit describes part of a circuit. Every bit...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is expected. EF Core uses the CLR default value to determine if it should use the SQL default. If it wasn’t nullable you could never save false:
With a
bool
property:With a
bool?
property:Hey Erik. Thanks for this!
We’re going to be making a refactoring pass on our database here in the next few weeks (major version increment). I’ve added a devops note to check this. If it’s helpful, I’ll respond here with confirmation.