dotnet / dotnet/format

dotnet format inserts invalid cast to delegate in moq code

Open
#1,748 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
1.9k
Forks
173
Avg merge
10d 13h
Merged PRs (30d)
1

Description

Given the following code

```
private static Mock CreateAugmentationBuilderWorkflow(string workflow, IList builders)
{
var augmentationBuilderWorkflowsMock = new Mock();
var workflows = new Dictionary();
var workflowMock = new Mock();
workflowMock.Setup(x => x.Name).Returns(workflow);
workflowMock.Setup(x => x.Builders).Returns(builders);
workflows.Add(workflow, workflowMock.Object);
augmentationBuilderWorkflowsMock.Setup(x => x.Workflows).Returns(workflows);
return augmentationBuilderWorkflowsMock;
}
```

dotnet format inserts the following cast from `Dictionary` to `Delegate`:
```
workflowMock.Setup(x => x.Builders).Returns((Delegate)builders);
```

I encountered this while ordering the using statements on > 6k files. This happened on about 8 files, which I found through `git diff -G Delegate` after unit tests on my build failed.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.