The source-code for System.Boolean
at the Reference Source website states that instances of the struct Boolean
contain only a single bool
field: private bool m_value
:
https://referencesource.microsoft.com/#mscorlib/system/boolean.cs,f1b135ff6c380b37
namespace System {
using System;
using System.Globalization;
using System.Diagnostics.Contracts;
[Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public struct Boolean : IComparable, IConvertible
#if GENERICS_WORK
, IComparable<Boolean>, IEquatable<Boolean>
#endif
{
private bool m_value;
internal const int True = 1;
internal const int False = 0;
internal const String TrueLiteral = "True";
internal const String FalseLiteral = "False";
public static readonly String TrueString = TrueLiteral;
public static readonly String FalseString = FalseLiteral;
}
But I noticed that...
bool
is a C# language alias forSystem.Boolean
.- The type is
struct Boolean
which is a value-type which means it cannot contain itself as a field. - ...yet this code presumably compiles.
- I understand that when the
-nostdlib
compiler option is set you need to provide your own essential type definitions likeSystem.String
,System.Int32
,System.Exception
- that's the only difference. - The published source-code contains no other special attributes like
[MethodImpl( MethodImplOptions.InternalCall )]
.
So how does this code compile?