Question Net 9 WFO1000

aaaron

Well-known member
Joined
Jan 23, 2011
Messages
223
Programming Experience
10+
I've been reading about the Net 9 serialization requirement. I don't understand it, but even if I did, I would have to study and manually add statements to about 1000 properties.

Am I understanding this correctly?
 
Solution
I recommend that you look into what DefaultValue attribute means and how it is used, and also read more about DesignerSerializationVisibility. If you're writing controls to be used by yourself or others in designer this matters, and it is not complicated. These attributes control if and how the property is serialized into the designer.vb code file.

If you're not writing controls that is meant to be designed just automatically apply the default DesignerSerializationVisibility.Hidden as suggested by VS and no harm is done.
I've never added code to serialize. Does that mean that DesignerSerializationVisibility.Hidden would always be correct?
 
No, it is the default for this rule, to avoid "Sensitive data being exposed in source code" which are "risks to the integrity and security of your application."
 
about 1000 properties

You have a lot of user controls or forms with custom properties. When I upgraded my 15 forms projects to .Net 9 I only encountered this for one property for a dialog class. My apps are not very complex though, and I basically never write user controls.
 
Oh, I got so many errors I assumed there was one for each of my properties.

I'm afraid I still don't understand what to look for in my code that would make it contain sensitive data. I'm completely baffed. I read and understand the words but can't relate it to any thing I know.
 
If a user control property doesn't either have DesignerSerializationVisibility or DefaultValue (or rarer ShouldSerialize*) you could inadevertly set a value for that property in designer that is not supposed to go into your compiled app/library - that's what the rule protects against.
 
I hate to drag this out but I don't understand what you just told me. Maybe an example would help?

VS is saying this does not configure code serialization for its property content. I don't know what that means. The first simply sets a Boolean variable.

VB.NET:
 Public Property HideDriveCheckBoxes() As Boolean
     Get
         Return Me.mHideDriveCheckBoxes
     End Get
     Set(value As Boolean)
         Me.mHideDriveCheckBoxes = value
     End Set
 End Property
 Public Property HideCheckedAddAttributes() As Boolean
     Get
         Return Not Me.ToolStripMenuItem_Checked_AddAttributes.Available
     End Get
     Set(hide As Boolean)
         Me.ToolStripSeparator_Checked_Sep1.Visible = Not hide
         Me.ToolStripMenuItem_Checked_AddAttributes.Visible = Not hide
         Me.ToolStripMenuItem_Checked_RemoveAttributes.Visible = Not hide
     End Set
 End Property
 
I recommend that you look into what DefaultValue attribute means and how it is used, and also read more about DesignerSerializationVisibility. If you're writing controls to be used by yourself or others in designer this matters, and it is not complicated. These attributes control if and how the property is serialized into the designer.vb code file.

If you're not writing controls that is meant to be designed just automatically apply the default DesignerSerializationVisibility.Hidden as suggested by VS and no harm is done.
 
Solution
Back
Top