Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warnings on unused fields not triggered when class is abstract #13652

Closed
TobiasBreuer opened this issue Sep 7, 2016 · 0 comments
Closed

Warnings on unused fields not triggered when class is abstract #13652

TobiasBreuer opened this issue Sep 7, 2016 · 0 comments
Assignees
Milestone

Comments

@TobiasBreuer
Copy link

Version Used: VS 2015 Update 3

Steps to Reproduce:

When having an abstract class containing private fields that are never assigned to or never read, the native compiler (VS 2012) used to issue related warnings CS0414 / CS0649. The roslyn compiler in VS 2015 however does only trigger these warnings when the class is not being marked as abstract.

For details please see my related StackOverflow question.

For a better overview, I add the minimal example on how to reproduce this issue here as well:

    // When the class is being marked as abstract, VS-2015 will not issue any warning.
    // When the class is not abstract the warnings are issued.
    public abstract class Demonstrator
    {
        // This should trigger warning CS0169 Warning Level 2
        private int _UnusedField;

        // This should trigger warning CS0414 Warning Level 4
        private int _AssignedButNotReadField;

        public Demonstrator()
        {
            _AssignedButNotReadField = 1;
        }
    }

The compiler should still trigger those warnings even though the class is abstract, as, due to the fact that those fields are private, their usage is still restricted to that single class.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants