This is a migrated thread and some comments may be shown as answers.

No error indicating that a readonly field is being assigned to where it can't

1 Answer 40 Views
Code Analysis
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Andrei
Top achievements
Rank 1
Andrei asked on 05 Jul 2012, 12:33 PM

Something like this:

public class MyClass
{
    private readonly int _lastId = 0;

    public int GetNextSequentialId()
    {
        return ++_lastId;
    }
}


JustCode doesn't find any error here but apparently this class cannot be compiled.

I understand the impact it may have on performance but I think you have multiple stages in the analysis process so important things get reported fast, and others later. This one can quality for 'others'. You can even run a compiler in the background.. I heard ReSharper does it.
On the other hand, you analyze each method anyway, for example, when determining unused variables or stuff that can be refactored. It probably wouldn't add much execution time to check what of kind of a field a method tries to use.

1 Answer, 1 is accepted

Sort by
0
Zdravko
Telerik team
answered on 09 Jul 2012, 11:51 AM
Hi Andrei,

 Thanks for the feedback.
I reviewed it and added it to our system for fixing.
Thank you for the help and have a nice day.

Greetings,
Zdravko
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
Code Analysis
Asked by
Andrei
Top achievements
Rank 1
Answers by
Zdravko
Telerik team
Share this question
or