Invalid CompilationRelaxations attribute

I have a simple console application in .net 4.5.

public class Program
{
    public static void Main ()
    {
        string s1 = "s1";
        string s2 = "s1";

        Console.WriteLine (ReferenceEquals (s1, s2));
    }
}

This gives true because of string interning. However, when I add the CompilationRelaxations attribute to the AssemblyInfo file, I still see true as output.

[assembly: compilationRelaxations (CompilationRelaxations.NoStringInterning)]

Even adding the attribute to my program class doesn't seem to change the result. [CompilationRelaxations (CompilationRelaxations.NoStringInterning)]

Changing it in .net 4.0 application also has no effect.

What am I missing?

0


source to share


1 answer


Here is a quote from the documentation :

Marks an assembly as not requiring string interpolation.



This does not prevent the compiler from doing string interning by simply indicating that it is not required. The documentation for it is pretty poor, both on MSDN and the CLI spec. See also MSDN Forum Post .

+1


source







All Articles