machine / machine.specifications

Machine.Specifications is a Context/Specification framework for .NET that removes language noise and simplifies tests.
MIT License
885 stars 178 forks source link

Annotations no longer working in R# #382

Closed ajj7060 closed 5 years ago

ajj7060 commented 5 years ago

Using the latest MSpec + R# (2019.1.0 and 2019.1.1) in VS 2019, the annotations don't appear to be working and R# says Establish, Because and It delegates are not used and can be removed.

If you open the Annotations settings in R#, it looks like they are still there, but if you clear the checkbox and Save the changes, when you come back they are gone from the custom annotations list.

Let me know if there's somehow more information I can gather.

robertcoltheart commented 5 years ago

Thanks for the report, I'll take a look but I might not get to this until next week.

robertcoltheart commented 5 years ago

I've looked into this, I don't think it's R# that's causing the issue, it seems like it's actually VS 2019 that is overwriting R# settings in terms of implicit usage. Nothing has changed in MSpec for annotations, so not sure what is going on.

robertcoltheart commented 5 years ago

Just to add to this, you know that the annotations only worked if you had a subject attribute on your class, right? It won't work if there is no subject.

robertcoltheart commented 5 years ago

I'm going to close this, as this appears to be either a VS or R# issue and not MSpec.

image

ajj7060 commented 5 years ago

yes, I know the annotations only works with a subject; it used to gray everything out until a Subject attribute was added somewhere.

Are you sure this isn't an mspec thing, because the namespace used to show in the Code Annotations settings in R#, and they don't anymore. When it showed, if you didn't check the checkbox for Machine.Specifications, it wouldn't use them either.

MSpecAnnotations

robertcoltheart commented 5 years ago

I suspect R# have changed the way the annotations propagate up to the settings UI, there's nothing that's changed in MSpec that would have affected this.

ajj7060 commented 5 years ago

I don't think its just a UI thing; clearly R# isn't recognizing the annotations for mspec anymore. Is this not the right place for issues related to mspec R# integration?

robertcoltheart commented 5 years ago

Consider the following cases:

1

No attributes or annotations image

R# reports the field as unused and text coloring shows as unused: image

2

With subject image

R# no longer reports as unused, but text coloring still indicates unused. image

If you add a public modifier, the text coloring changes to used, which indicates that either R# or the Roslyn analyzer is automatically treating private fields as unused. image

3

With normal R# annotations image

R# doesn't report as unused, text coloring indicates unused, same as in case 2. image

Adding a public modifier exhibits the same behavior as in case 2. image

I hope that's comprehensive enough for you. Bottom line, you won't get warnings in your build if you are running R# analyzers, but the text coloring appears to be off. I'd suggest raising a ticket over at https://youtrack.jetbrains.com if it still bothers you. An alternative is to implement project-level settings using R# settings layers, and fix it that way.