Refactor > Move to folder > Usage of decimal cannot be updated correctly

Completed

I have a static class with a single static method in one project (this is a simplified example, but I get the same result):

public static class AverageScoreCalculator
{
    public static decimal? GetAverageScore(int? sum, int? numberOfQuestions)
    {
        if (sum == null || numberOfQuestions == null || numberOfQuestions.Value == 0) return null;

        var average = (decimal)sum.Value / numberOfQuestions.Value;

        return Math.Round(average, 2);
    }
}

I'm moving this class to a different project using Refactor this > Move to Folder. This gives me an unexpected warning about conflicts:

What is the cause of these conflicts? I can't see that there should be anything wrong, or difficulties related to moving this class. (The simplified example isn't even used in my code, so there is no dependencies to it either.)

And if I continue with the refactoring by pressing Next, the class is moved to the other project and everything is just fine. So it appears that these conflicts are false negatives. Or am I missing something?

Can it have something to do with the two involved projects having different target frameworks? The project I'm moving the class from is .NET Framework 4.8, whilst the project I'm moving to is .NET Standard 2.0 (both are of type Class Library). I can't see why this should matter though - it is just an idea.

0
3 comments

Hello Julian,

Thank you for contacting us.

Indeed, you see the conflict dialog due to different target frameworks between the two projects. ReSharper compares how to resolve types from the first project to the second project. If there is a difference between the exact reference to where this type is finally resolved, ReSharper will fire the conflict dialog. In the case you provided, you are lucky not to get the errors in the resulting file. Trying to move something more complicated between two different target frameworks might lead to errors.

0

Thank you for getting back to me Elena Kurakina.

I understand that moving types between different target frameworks might cause problems. But I would also argue that the conflict message ReSharper provides now is not much helpful. "Usage of decimal cannot be updated correctly" makes it sound like ReSharper has tried - and failed - to update the usage of specific line of code. Which is indeed not the case. Something more generic, "Moving types between target frameworks might cause errors" like you explained, would be easier to understand.

0

Hello Julian,

Please accept my apologies for the delay in the reply.

I discussed this feature request with our development team and opened a corresponding issue - https://youtrack.jetbrains.com/issue/RSRP-490060.

Feel free to comment or vote for it.

0

Please sign in to leave a comment.