jeudi 23 juin 2016

webapi controllers with name "<>c"

I have a unit test ensure my WebAPI controllers derive from the right base type:

[TestMethod]
public void AllWebApiControllersShouldDeriveFromApiController()
{
    var controllers = Assembly.GetAssembly(typeof(ApiControllerBase)).GetTypes()
        .Where(t => t.Namespace == "Xxx.Web.Controllers")
        .ToList();

    controllers.Should().NotBeEmpty();

    foreach (var controller in controllers)
    {
        if (controller == typeof(ApiControllerBase)) continue;

        controller.Should().BeDerivedFrom<ApiControllerBase>();
    }
}

it was working fine until recently, when all of a sudden in the list of controllers two "ghost" controllers started to appear. They look like some sort of generic (auto-generated?) types and they are failing my tests. These are:

Name = "<>c" FullName = "Xxx.Web.Controllers.ExistingControllerNameController+<>c"

They are failing my test above. What are they? Where did they come from? How can I get rid of them?

N.B. test is failing on the build server as well. Clean & Rebuild did not help.

Aucun commentaire:

Enregistrer un commentaire