Joan Venge
Joan Venge

Reputation: 330892

What does this .NET attribute do?

 [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]

I saw this attribute in the reflector for the base class libraries in .NET. Maybe immutable guarantees are supported internally?

Upvotes: 2

Views: 198

Answers (2)

Sam Saffron
Sam Saffron

Reputation: 131112

Read up about it here and here.

The short summary is that its instructing the runtime to guarantee execution of finally blocks in the face of any async exceptions (like ThreadAbortException).

The standard CLR host will hold off aborting thread while finally blocks are executing.

However, when SQL Server hosts the CLR is may trigger rude aborts which can happen while the CLR is running finally clauses. In these kind of cases, CERs are used to ensure state does not corrupt.

There are certain requirement you must meet inside CERs (For example, you are not allowed to box stuff inside a CER).

Upvotes: 5

Thomas Levesque
Thomas Levesque

Reputation: 292385

It has nothing to do with immutability, check the MSDN documentation

Upvotes: 1

Related Questions