To ensure coding standards I have a couple of unit test which uses reflection to see that nothing is wrong. One of those looks like this:
[Test]
public void All_structs_should_be_immutable()
{
var mutableStructs = typeof (Product).Assembly
.GetTypes()
.Where(type =>
type.IsValueType && !type.IsCompilerGenerated() &&
!type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).All(
field => field.IsInitOnly))
.OrderBy(type => type.FullName);
foreach (var mutableStruct in mutableStructs)
{
Console.WriteLine(mutableStruct.FullName);
}
Assert.AreEqual("", string.Join(", ", mutableStructs.Select(x => x.FullName).ToArray()));
Assert.AreEqual(0, mutableStructs.Count());
}
The Product class is within my own assembly which has nothing to do with Jetbrains/Teamcity.
This works fine when running the tests with Resharper. But when I run it in Teamcity, I get this error:
Test(s) failed. Expected string length 0 but was 51. Strings differ at index 0.
Expected:
But was: "JetBrains.Profiler.Core.Instrumentation.DataOnStack"
-----------^
at NUnit.Framework.Assert.That(Object actual, IResolveConstraint expression, String message, Object[] args)
at NUnit.Framework.Assert.AreEqual(Object expected, Object actual)
at Litium.Kamakura.UnitTest.CodingStandards.ImmutableStructs.All_structs_should_be_immutable() in c:\TeamCity\buildAgent\work\99395abb82d2a3b3\Test\Litium.Kamakura.UnitTest\CodingStandards\ImmutableStructs.cs:line 26
------- Stdout: -------
JetBrains.Profiler.Core.Instrumentation.DataOnStack
How and why does Teamcity modify my assembly?