Coverlet changes order of attributes
See original GitHub issueVersions: dotnet core 2.1 asp.net core 2.1.5 coverlet 2.5.0
Some of our tests that rely on the order of asp.net ValidationAttribute
s for method parameters fail when run with coverlet. Coverlet instrumentation seems to change the order of attributes.
e.g.
method.GetParameters().ForEach(p =>
{
var validationAttributes = p.CustomAttributes.Where(a => typeof(ValidationAttribute).IsAssignableFrom(a.AttributeType))
.Select(a => a.AttributeType).ToList();
if (validationAttributes.All(a => a != typeof(ShouldBeFirstAttribute))) return;
if (validationAttributes.First() != typeof(ShouldBeFirstAttribute))
{
Assert.Fail("Action: {0}.{1}(...) should have {2} declared before other validation attributes", type.FullName, method.Name,
typeof(ShouldBeFirstAttribute).Name);
}
});
This passes when run with \p:CodeCoverage=false
Issue Analytics
- State:
- Created 5 years ago
- Comments:8
Top Results From Across the Web
coverlet-coverage/coverlet: Cross platform code ...
Coverlet is a cross platform code coverage framework for .NET, with support for line, branch and method coverage. It works with .NET Framework...
Read more >Coverlet is not considering the excludefromCoverage ...
Hi, I'm using the Coverlet to measure .NET core 3.1 Web API code coverage. I have used entity framework for creating by repository....
Read more >Is it possible to change order of attributes when toJson()?
The problem about changing the order is "How can I do that for an inherited class?" as in my example. It extracts the...
Read more >Implementing Order Management
To ignore changes to all extensible flexfield values, make sure Use Flexfield Attributes for each step in the Change Management area isn't enabled....
Read more >Changing the order of block attributes in AutoCAD
Solution: To change the order of block attributes. Use the BATTORDER (Command) which specifies the order of attributes for a block.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks @MarcoRossignoli! Just found a workaround till then, i’ll use the Order property of ActionFilterAttribute: https://docs.microsoft.com/en-us/aspnet/core/mvc/controllers/filters?view=aspnetcore-2.2#overriding-the-default-order
@dorgold I opened a PR to upgrade Cecil lib https://github.com/tonerdo/coverlet/pull/508 to avoid reordering…you can use nightly untill next release https://github.com/tonerdo/coverlet/blob/master/Documentation/ConsumeNightlyBuild.md