Search Issue Tracker

Postponed means that the issue was either a feature request or something that requires major refactoring on our side. Since that makes the issue not actionable in the close future we choose to close it as Postponed and add it on our internal roadmaps and technical debt pages instead.

Postponed

Votes

10

Found in

2018.3.0a1

2018.3.0b1

Issue ID

1080427

Regression

Yes

[SerializedField] fields produce "Field is never assigned to..." warning

Mono

-

1. Open the attached project (warning.zip)
2. Observe the warning in the console

Expected: field with SerializeField attribute do not produce the warning

Reproduced in 2018.3.0a1, 2018.3.0b1, 2018.3.0b2, 2019.1.0a1
Did not reproduce in 2018.2.8f1
Regression introduced in 2018.3.0a1

  1. Response avatar

    lukaszunity

    Nov 06, 2019

    #pragma warning disable 0649
    // your code
    #pragma warning restore 0649

    Or disable it globally by adding a file named csc.rsp to the root of you Assets folder, e.g. Assets/csc.rsp, with the following contents without quotes.

    /nowarn:0649

    This will tell the C# compiler to not emit a warning for CS0649 / unused fields.

    If you have .asmdefs with csc.rsp in your project, then you also need to add the "/nowarn:0649" line to those csc.rsp files.

  1. Response avatar

    Resolution Note (fix version ):

    This can be fixed using DiagnosticSuppressor API in Roslyn. However, this requires that Unity updates Roslyn to a newer version that supports DiagnosticSuppressor and that proper support for using Roslyn analyzers is added to Unity. The fix of this issue is therefore postponed.

    The new C# compiler is correct in reporting the additional warnings.

    You can disable the warnings with pragmas:

    #pragma warning disable 0649
    // your code
    #pragma warning restore 0649

    Or disable it globally by adding a csc.rsp file to your project and adding command line switch to disable the warning.

Comments (59)

  1. 51623c5ba2d7468394521762e2cc7009?d=mm

    transat

    Oct 08, 2019 04:30

    Using Unity's own preview Standard Assets Controller, I get 120+ issues in my console because of this. Surely there has to be a better solution than just saying "by design"?

  2. 3e64d071a0d538d0b88040e4bfa22d2d?d=mm

    ShadowOfEclipse

    Oct 06, 2019 22:34

    Agreed that this should be re-investigated.

  3. E295481e81a54f69223bd408552c5a1e?d=mm

    JillCrungus

    Sep 26, 2019 16:33

    This is blatantly NOT intended functionality and the proposed solutions are just workarounds for a bug that should not have been marked resolved.

  4. E7450742b0fb9c4c69426524978c3043?d=mm

    Jokerminator

    Sep 23, 2019 19:58

    Damn this is bugging!

  5. 5fa445a7e382ed309aab2097ea215163?d=mm

    sabras

    Sep 23, 2019 14:18

    Please reopen, its really annoying

  6. F25db945e005add93f29ca8e53869f17?d=mm

    AmitSuri

    Sep 21, 2019 20:52

    This needs a solution. You can't just say "By design" without an actual alternative solution.
    If this is by design then fire your designers and find better ones.

  7. 55d14f6d8457d63f7573846de069a09b?d=mm

    KarolStolaDD

    Sep 20, 2019 10:26

    Reopen this, please...

  8. 29b7224f3299d49bbc1741626aaeab16?d=mm

    vElumi

    Sep 18, 2019 11:47

    +1 for reopen....

  9. Bd8ae845fd68eef42682d25b6e516e0a?d=mm

    domFC

    Sep 17, 2019 19:18

    This makes it really hard to see real warnings. Please fix this.

  10. 8dd865676b3397338a01a5b4b71383c8?d=mm

    F-N

    Sep 11, 2019 07:32

    Poor design. Really Unity, just fix this...

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.