Skip to content

IDE0044 (Make Field Readonly) Should not warn for DataMember fields in DataContract classes #40644

@steevcoco

Description

@steevcoco

Version Used:

Microsoft Visual Studio Community 2019
Version 16.4.2
Microsoft .NET Framework
4.8.03752

Steps to Reproduce:

In a class marked DataContract, create a private field, NOT readonly, and marked DataMember.

[DataContract]
public class MyClass
{
	[DataMember]
	private bool isReadOnly;
}

Expected Behavior:

The field cannot be readonly because it is a DataMember.

Actual Behavior:

The IDE warns with "IDE0044 (Make Field Readonly)".

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-IDEBugFeature - IDE0044Make field readonlyResolution-FixedThe bug has been fixed and/or the requested behavior has been implemented

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions