Skip to content

readonly ref and in parameters removes warning CS0649: Field 'field' was never assigned to. #77528

@itsBuggingMe

Description

@itsBuggingMe

Version Used:
Not sure - I found the error while using sharplab.

Steps to Reproduce:

  1. Create a private unused field in a class or struct.
  2. Pass the private field as ref readonly or in into a method.

Repro (edited)

Diagnostic Id:

CS0649: Field 'field' is never assigned to, and will always have its default value 'value'.

Expected Behavior:

The warning still persists, even when the field is passed by a readonly reference into a method.

Actual Behavior:

Warning is removed.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions