Type of issue
Code does not work
Description
Example states:
[NonSerialized]
public ExampleClass ExampleProperty {get; set;}
however:
https://learn.microsoft.com/en-us/dotnet/api/system.nonserializedattribute?view=net-10.0
[System.AttributeUsage(System.AttributeTargets.Field, Inherited=false)]
public sealed class NonSerializedAttribute : Attribute
produces the following error:
CS0592: Attribute 'NonSerialized' is not valid on this declaration type. It is only valid on 'field' declarations.
please note that just changing the Atribute to [field: NonSerialized] does not "work", as it will raise the Analyzer CA5362 again
Page URL
https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca5362
Content source URL
https://github.com/dotnet/docs/blob/main/docs/fundamentals/code-analysis/quality-rules/ca5362.md
Document Version Independent Id
5bb21412-9df3-42bd-d423-62b2e12d93f7
Platform Id
8f5f157c-f4cf-76e7-438a-c2b74c5220c3
Article author
@LLLXXXCCC
Metadata
- ID: 59c0feae-5e7a-9738-7f00-04bfda5c7752
- PlatformId: 8f5f157c-f4cf-76e7-438a-c2b74c5220c3
- Service: dotnet-fundamentals
Related Issues
Associated WorkItem - 601485
Type of issue
Code does not work
Description
Example states:
however:
https://learn.microsoft.com/en-us/dotnet/api/system.nonserializedattribute?view=net-10.0
produces the following error:
please note that just changing the Atribute to
[field: NonSerialized]does not "work", as it will raise the Analyzer CA5362 againPage URL
https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca5362
Content source URL
https://github.com/dotnet/docs/blob/main/docs/fundamentals/code-analysis/quality-rules/ca5362.md
Document Version Independent Id
5bb21412-9df3-42bd-d423-62b2e12d93f7
Platform Id
8f5f157c-f4cf-76e7-438a-c2b74c5220c3
Article author
@LLLXXXCCC
Metadata
Related Issues
Associated WorkItem - 601485