Imported Upstream version 4.6.0.150

Former-commit-id: 73e3bb1e96dd09dc931c1dfe559d2c7f7b8b02c7
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2016-08-23 13:20:38 +00:00
parent 02ac915603
commit b95516a3dd
239 changed files with 4096 additions and 1544 deletions

View File

@ -60,12 +60,90 @@ namespace Microsoft.Win32
throw new PlatformNotSupportedException ();
}
public RegistryKey CreateSubKey (String subkey, bool writable)
{
throw new PlatformNotSupportedException ();
}
public RegistryKey CreateSubKey (String subkey, bool writable, RegistryOptions options)
{
throw new PlatformNotSupportedException ();
}
public void DeleteSubKey (string subkey)
{
}
public void DeleteSubKey (string subkey, bool throwOnMissingSubKey)
{
}
public void DeleteSubKeyTree (string subkey)
{
}
public void DeleteSubKeyTree (string subkey, bool throwOnMissingSubKey)
{
}
public void DeleteValue (string name)
{
}
public void DeleteValue (string name, bool throwOnMissingValue)
{
}
public void Flush()
{
}
public static RegistryKey FromHandle (SafeRegistryHandle handle)
{
throw new PlatformNotSupportedException ();
}
public static RegistryKey FromHandle (SafeRegistryHandle handle, RegistryView view)
{
throw new PlatformNotSupportedException ();
}
public string[] GetSubKeyNames ()
{
throw new PlatformNotSupportedException ();
}
public object GetValue (string name)
{
throw new PlatformNotSupportedException ();
}
public object GetValue (string name, object defaultValue)
{
throw new PlatformNotSupportedException ();
}
public static object GetValue (string keyName, string valueName, object defaultValue)
public object GetValue (string name, object defaultValue, RegistryValueOptions options)
{
throw new PlatformNotSupportedException ();
}
public RegistryValueKind GetValueKind (string name)
{
throw new PlatformNotSupportedException ();
}
public string[] GetValueNames ()
{
throw new PlatformNotSupportedException ();
}
public static RegistryKey OpenBaseKey (RegistryHive hKey, RegistryView view)
{
throw new PlatformNotSupportedException ();
}
public RegistryKey OpenSubKey (string name)
{
throw new PlatformNotSupportedException ();
}
@ -75,6 +153,11 @@ namespace Microsoft.Win32
throw new PlatformNotSupportedException ();
}
public RegistryKey OpenSubKey (string name, RegistryRights rights)
{
throw new PlatformNotSupportedException ();
}
public void SetValue (string name, object value)
{
}
@ -83,7 +166,25 @@ namespace Microsoft.Win32
{
}
// TODO: Finish full contract API
public SafeRegistryHandle Handle {
get { throw new PlatformNotSupportedException (); }
}
public string Name {
get { throw new PlatformNotSupportedException (); }
}
public int SubKeyCount {
get { throw new PlatformNotSupportedException (); }
}
public int ValueCount {
get { throw new PlatformNotSupportedException (); }
}
public RegistryView View {
get { throw new PlatformNotSupportedException (); }
}
}
#else
/// <summary>
@ -389,7 +490,18 @@ namespace Microsoft.Win32
return CreateSubKey (subkey, permissionCheck, registryOptions);
}
[ComVisible(false)]
public RegistryKey CreateSubKey (string subkey, bool writable)
{
return CreateSubKey (subkey, writable ? RegistryKeyPermissionCheck.ReadWriteSubTree : RegistryKeyPermissionCheck.ReadSubTree);
}
[ComVisible(false)]
public RegistryKey CreateSubKey (string subkey, bool writable, RegistryOptions options)
{
return CreateSubKey (subkey, writable ? RegistryKeyPermissionCheck.ReadWriteSubTree : RegistryKeyPermissionCheck.ReadSubTree, options);
}
/// <summary>
/// Delete the specified subkey.
/// </summary>
@ -589,7 +701,14 @@ namespace Microsoft.Win32
{
return OpenSubKey (name, permissionCheck == RegistryKeyPermissionCheck.ReadWriteSubTree);
}
[ComVisible (false)]
[MonoLimitation ("rights are ignored in Mono")]
public RegistryKey OpenSubKey (string name, RegistryRights rights)
{
return OpenSubKey (name);
}
[ComVisible (false)]
[MonoLimitation ("rights are ignored in Mono")]
public RegistryKey OpenSubKey (string name, RegistryKeyPermissionCheck permissionCheck, RegistryRights rights)

View File

@ -41,12 +41,15 @@ namespace System.Diagnostics.Tracing
get; private set;
}
public EventActivityOptions ActivityOptions { get; set; }
public EventLevel Level { get; set; }
public EventKeywords Keywords { get; set; }
public EventOpcode Opcode { get; set; }
public EventChannel Channel { get; set; }
public string Message { get; set; }
public EventTask Task { get; set; }
public EventTags Tags { get; set; }
public byte Version { get; set; }
}
}

View File

@ -28,6 +28,7 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Collections.Generic;
namespace System.Diagnostics.Tracing
{
@ -76,6 +77,11 @@ namespace System.Diagnostics.Tracing
{
}
~EventSource ()
{
Dispose (false);
}
public Exception ConstructionException
{
get { return null; }
@ -121,6 +127,7 @@ namespace System.Diagnostics.Tracing
public void Dispose ()
{
Dispose (true);
GC.SuppressFinalize (this);
}
public string GetTrait (string key)
@ -132,6 +139,10 @@ namespace System.Diagnostics.Tracing
{
}
public void Write (string eventName, EventSourceOptions options)
{
}
public void Write<T> (string eventName, T data)
{
}
@ -244,6 +255,75 @@ namespace System.Diagnostics.Tracing
{
WriteEvent (eventId, new object[] { arg1, arg2, arg3 } );
}
protected unsafe void WriteEventCore (int eventId, int eventDataCount, EventData* data)
{
}
protected unsafe void WriteEventWithRelatedActivityId (int eventId, Guid relatedActivityId, params object[] args)
{
}
protected unsafe void WriteEventWithRelatedActivityIdCore (int eventId, Guid* relatedActivityId, int eventDataCount, EventSource.EventData* data)
{
}
#if NETSTANDARD
[MonoTODO]
public event EventHandler<EventCommandEventArgs> EventCommandExecuted
{
add { throw new NotImplementedException (); }
remove { throw new NotImplementedException (); }
}
#endif
[MonoTODO]
public static string GenerateManifest (Type eventSourceType, string assemblyPathToIncludeInManifest)
{
throw new NotImplementedException ();
}
[MonoTODO]
public static string GenerateManifest (Type eventSourceType, string assemblyPathToIncludeInManifest, EventManifestOptions flags)
{
throw new NotImplementedException ();
}
[MonoTODO]
public static Guid GetGuid (Type eventSourceType)
{
throw new NotImplementedException ();
}
[MonoTODO]
public static string GetName (Type eventSourceType)
{
throw new NotImplementedException ();
}
[MonoTODO]
public static IEnumerable<EventSource> GetSources ()
{
throw new NotImplementedException ();
}
[MonoTODO]
public static void SendCommand (EventSource eventSource, EventCommand command, IDictionary<string, string> commandArguments)
{
throw new NotImplementedException ();
}
[MonoTODO]
public static void SetCurrentThreadActivityId (Guid activityId)
{
throw new NotImplementedException ();
}
[MonoTODO]
public static void SetCurrentThreadActivityId (Guid activityId, out Guid oldActivityThatWillContinue)
{
throw new NotImplementedException ();
}
}
}

View File

@ -178,6 +178,20 @@ namespace System.Diagnostics {
return frames;
}
static bool isAotidSet;
static string aotid;
static string GetAotId ()
{
if (!isAotidSet) {
aotid = Assembly.GetAotId ();
if (aotid != null)
aotid = new Guid (aotid).ToString ("N");
isAotidSet = true;
}
return aotid;
}
bool AddFrames (StringBuilder sb)
{
bool printOffset;
@ -215,8 +229,18 @@ namespace System.Diagnostics {
sb.AppendFormat (" [0x{0:x5}]", frame.GetILOffset ());
}
sb.AppendFormat (debugInfo, frame.GetSecureFileName (),
frame.GetFileLineNumber ());
var filename = frame.GetSecureFileName ();
if (filename[0] == '<') {
var mvid = frame.GetMethod ().Module.ModuleVersionId.ToString ("N");
var aotid = GetAotId ();
if (frame.GetILOffset () != -1 || aotid == null) {
filename = string.Format ("<{0}>", mvid);
} else {
filename = string.Format ("<{0}#{1}>", mvid, aotid);
}
}
sb.AppendFormat (debugInfo, filename, frame.GetFileLineNumber ());
}
}
@ -287,8 +311,6 @@ namespace System.Diagnostics {
if (!t.AddFrames (sb))
continue;
t.AddMetadata (sb);
sb.Append (Environment.NewLine);
sb.Append ("--- End of stack trace from previous location where exception was thrown ---");
sb.Append (Environment.NewLine);
@ -296,78 +318,14 @@ namespace System.Diagnostics {
}
AddFrames (sb);
AddMetadata (sb);
return sb.ToString ();
}
void AddMetadata (StringBuilder sb)
{
if (metadataHandlers == null)
InitMetadataHandlers ();
foreach (var handler in metadataHandlers) {
var lines = handler.Value (this);
using (var reader = new StringReader (lines)) {
string line;
while ((line = reader.ReadLine()) != null) {
sb.AppendLine ();
sb.AppendFormat ("[{0}] {1}", handler.Key, line);
}
}
}
}
internal String ToString (TraceFormat traceFormat)
{
// TODO:
return ToString ();
}
static void InitMetadataHandlers ()
{
metadataHandlers = new Dictionary<string, Func<StackTrace, string>> (StringComparer.Ordinal);
var aotid = Assembly.GetAotId ();
if (aotid != null)
AddMetadataHandler ("AOTID", st => { return new Guid (aotid).ToString ("N"); });
AddMetadataHandler ("MVID", st => {
var mvidLines = new Dictionary<Guid, List<int>> ();
var frames = st.GetFrames ();
for (var lineNumber = 0; lineNumber < frames.Length; lineNumber++) {
var method = frames[lineNumber].GetMethod ();
if (method == null)
continue;
var mvid = method.Module.ModuleVersionId;
List<int> lines = null;
if (!mvidLines.TryGetValue (mvid, out lines)) {
lines = new List<int> ();
mvidLines.Add (mvid, lines);
}
lines.Add (lineNumber);
}
var mvids = new List<Guid> (mvidLines.Keys);
mvids.Sort ();
var sb = new StringBuilder ();
foreach (var mvid in mvids)
sb.AppendLine (string.Format ("{0} {1}", mvid.ToString ("N"), string.Join (",", mvidLines[mvid])));
return sb.ToString ();
});
}
// This method signature should not change, apps can use it with reflection to add custom metadata handlers.
private static void AddMetadataHandler (string id, Func<StackTrace, string> handler)
{
if (metadataHandlers == null)
InitMetadataHandlers ();
metadataHandlers.Add (id, handler);
}
}
}

View File

@ -68,6 +68,12 @@ namespace System.Runtime.InteropServices
#endif
}
[MonoTODO]
public static bool AreComObjectsAvailableForCleanup ()
{
return false;
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public extern static IntPtr AllocCoTaskMem (int cb);
@ -341,6 +347,12 @@ namespace System.Runtime.InteropServices
#endif
}
[MonoTODO]
public static IntPtr GetComInterfaceForObject (object o, Type T, CustomQueryInterfaceMode mode)
{
throw new NotImplementedException ();
}
public static IntPtr GetComInterfaceForObject<T, TInterface> (T o) {
return GetComInterfaceForObject ((object)o, typeof (T));
}

View File

@ -33,11 +33,20 @@ namespace System.Security.AccessControl
{
public sealed class AuthorizationRuleCollection : ReadOnlyCollectionBase
{
public AuthorizationRuleCollection ()
{
}
internal AuthorizationRuleCollection (AuthorizationRule [] rules)
{
InnerList.AddRange (rules);
}
public void AddRule (AuthorizationRule rule)
{
InnerList.Add (rule);
}
public AuthorizationRule this [int index] {
get { return (AuthorizationRule) InnerList [index]; }
}

View File

@ -216,7 +216,19 @@ namespace System.Security.AccessControl
if (!preserveInheritance && SystemAcl != null)
SystemAcl.RemoveInheritedAces ();
}
public void AddDiscretionaryAcl (byte revision, int trusted)
{
DiscretionaryAcl = new DiscretionaryAcl (IsContainer, IsDS, revision, trusted);
flags |= ControlFlags.DiscretionaryAclPresent;
}
public void AddSystemAcl(byte revision, int trusted)
{
SystemAcl = new SystemAcl (IsContainer, IsDS, revision, trusted);
flags |= ControlFlags.SystemAclPresent;
}
void CheckAclConsistency (CommonAcl acl)
{
if (IsContainer != acl.IsContainer)

View File

@ -71,7 +71,12 @@ namespace System.Security.AccessControl
inheritanceFlags, propagationFlags, AuditFlags.None,
objectFlags, objectType, inheritedObjectType);
}
public void AddAccess (AccessControlType accessType, SecurityIdentifier sid, ObjectAccessRule rule)
{
AddAccess (accessType, sid, rule.AccessMask, rule.InheritanceFlags, rule.PropagationFlags, rule.ObjectFlags, rule.ObjectType, rule.InheritedObjectType);
}
[MonoTODO]
public bool RemoveAccess (AccessControlType accessType,
SecurityIdentifier sid,
@ -94,7 +99,12 @@ namespace System.Security.AccessControl
{
throw new NotImplementedException ();
}
public bool RemoveAccess (AccessControlType accessType, SecurityIdentifier sid, ObjectAccessRule rule)
{
return RemoveAccess (accessType, sid, rule.AccessMask, rule.InheritanceFlags, rule.PropagationFlags, rule.ObjectFlags, rule.ObjectType, rule.InheritedObjectType);
}
public void RemoveAccessSpecific (AccessControlType accessType,
SecurityIdentifier sid,
int accessMask,
@ -118,7 +128,12 @@ namespace System.Security.AccessControl
inheritanceFlags, propagationFlags, AuditFlags.None,
objectFlags, objectType, inheritedObjectType);
}
public void RemoveAccessSpecific (AccessControlType accessType, SecurityIdentifier sid, ObjectAccessRule rule)
{
RemoveAccessSpecific (accessType, sid, rule.AccessMask, rule.InheritanceFlags, rule.PropagationFlags, rule.ObjectFlags, rule.ObjectType, rule.InheritedObjectType);
}
public void SetAccess (AccessControlType accessType,
SecurityIdentifier sid,
int accessMask,
@ -142,7 +157,12 @@ namespace System.Security.AccessControl
inheritanceFlags, propagationFlags, AuditFlags.None,
objectFlags, objectType, inheritedObjectType);
}
public void SetAccess (AccessControlType accessType, SecurityIdentifier sid, ObjectAccessRule rule)
{
SetAccess (accessType, sid, rule.AccessMask, rule.InheritanceFlags, rule.PropagationFlags, rule.ObjectFlags, rule.ObjectType, rule.InheritedObjectType);
}
internal override void ApplyCanonicalSortToExplicitAces ()
{
int explicitCount = GetCanonicalExplicitAceCount ();

View File

@ -39,7 +39,11 @@ namespace System.Security.AccessControl
{
public abstract class ObjectSecurity
{
internal ObjectSecurity (CommonSecurityDescriptor securityDescriptor)
protected ObjectSecurity ()
{
}
protected ObjectSecurity (CommonSecurityDescriptor securityDescriptor)
{
if (securityDescriptor == null)
throw new ArgumentNullException ("securityDescriptor");

View File

@ -71,7 +71,12 @@ namespace System.Security.AccessControl
inheritanceFlags, propagationFlags, auditFlags,
objectFlags, objectType, inheritedObjectType);
}
public void AddAudit (SecurityIdentifier sid, ObjectAuditRule rule)
{
AddAudit (rule.AuditFlags, sid, rule.AccessMask, rule.InheritanceFlags, rule.PropagationFlags, rule.ObjectFlags, rule.ObjectType, rule.InheritedObjectType);
}
[MonoTODO]
public bool RemoveAudit (AuditFlags auditFlags,
SecurityIdentifier sid,
@ -94,7 +99,12 @@ namespace System.Security.AccessControl
{
throw new NotImplementedException ();
}
public bool RemoveAudit (SecurityIdentifier sid, ObjectAuditRule rule)
{
return RemoveAudit (rule.AuditFlags, sid, rule.AccessMask, rule.InheritanceFlags, rule.PropagationFlags, rule.ObjectFlags, rule.ObjectType, rule.InheritedObjectType);
}
public void RemoveAuditSpecific (AuditFlags auditFlags,
SecurityIdentifier sid,
int accessMask,
@ -120,7 +130,12 @@ namespace System.Security.AccessControl
objectFlags, objectType, inheritedObjectType);
}
public void RemoveAuditSpecific (SecurityIdentifier sid, ObjectAuditRule rule)
{
RemoveAuditSpecific (rule.AuditFlags, sid, rule.AccessMask, rule.InheritanceFlags, rule.PropagationFlags, rule.ObjectFlags, rule.ObjectType, rule.InheritedObjectType);
}
public void SetAudit (AuditFlags auditFlags,
SecurityIdentifier sid,
int accessMask,
@ -144,7 +159,12 @@ namespace System.Security.AccessControl
inheritanceFlags, propagationFlags, auditFlags,
objectFlags, objectType, inheritedObjectType);
}
public void SetAudit (SecurityIdentifier sid, ObjectAuditRule rule)
{
SetAudit (rule.AuditFlags, sid, rule.AccessMask, rule.InheritanceFlags, rule.PropagationFlags, rule.ObjectFlags, rule.ObjectType, rule.InheritedObjectType);
}
internal override void ApplyCanonicalSortToExplicitAces ()
{
int explicitCount = GetCanonicalExplicitAceCount ();

View File

@ -183,6 +183,18 @@ namespace System.Security.Principal {
return new WindowsImpersonationContext (userToken);
}
[SecuritySafeCritical]
public static void RunImpersonated (SafeAccessTokenHandle safeAccessTokenHandle, Action action)
{
throw new NotImplementedException ();
}
[SecuritySafeCritical]
public static T RunImpersonated<T> (SafeAccessTokenHandle safeAccessTokenHandle, Func<T> func)
{
throw new NotImplementedException ();
}
// properties
sealed override
public string AuthenticationType {

View File

@ -782,6 +782,183 @@ namespace System
if (exit)
Environment.Exit (58);
}
#else
// largely inspired by https://github.com/dotnet/corefx/blob/be8d2ce3964968cec9322a64211e37682085db70/src/System.Console/src/System/ConsolePal.WinRT.cs, because it's a similar platform where a console might not be available
// provide simply color tracking that allows round-tripping
internal const ConsoleColor UnknownColor = (ConsoleColor)(-1);
private static ConsoleColor s_trackedForegroundColor = UnknownColor;
private static ConsoleColor s_trackedBackgroundColor = UnknownColor;
public static ConsoleColor ForegroundColor
{
get
{
return s_trackedForegroundColor;
}
set
{
lock (Console.Out) // synchronize with other writers
{
s_trackedForegroundColor = value;
}
}
}
public static ConsoleColor BackgroundColor
{
get
{
return s_trackedBackgroundColor;
}
set
{
lock (Console.Out) // synchronize with other writers
{
s_trackedBackgroundColor = value;
}
}
}
public static int BufferWidth
{
get { throw new PlatformNotSupportedException (); }
set { throw new PlatformNotSupportedException (); }
}
public static int BufferHeight
{
get { throw new PlatformNotSupportedException (); }
set { throw new PlatformNotSupportedException (); }
}
public static bool CapsLock { get { throw new PlatformNotSupportedException (); } }
public static int CursorLeft
{
get { throw new PlatformNotSupportedException (); }
set { throw new PlatformNotSupportedException (); }
}
public static int CursorTop
{
get { throw new PlatformNotSupportedException (); }
set { throw new PlatformNotSupportedException (); }
}
public static int CursorSize
{
get { return 100; }
set { throw new PlatformNotSupportedException(); }
}
public static bool CursorVisible
{
get { throw new PlatformNotSupportedException (); }
set { throw new PlatformNotSupportedException (); }
}
public static bool KeyAvailable { get { throw new PlatformNotSupportedException (); } }
public static int LargestWindowWidth
{
get { throw new PlatformNotSupportedException (); }
set { throw new PlatformNotSupportedException (); }
}
public static int LargestWindowHeight
{
get { throw new PlatformNotSupportedException (); }
set { throw new PlatformNotSupportedException (); }
}
public static bool NumberLock { get { throw new PlatformNotSupportedException (); } }
public static string Title
{
get { throw new PlatformNotSupportedException (); }
set { throw new PlatformNotSupportedException (); }
}
public static bool TreatControlCAsInput
{
get { throw new PlatformNotSupportedException (); }
set { throw new PlatformNotSupportedException (); }
}
public static int WindowHeight
{
get { throw new PlatformNotSupportedException (); }
set { throw new PlatformNotSupportedException (); }
}
public static int WindowLeft
{
get { return 0; }
set { throw new PlatformNotSupportedException (); }
}
public static int WindowTop
{
get { return 0; }
set { throw new PlatformNotSupportedException (); }
}
public static int WindowWidth
{
get { throw new PlatformNotSupportedException (); }
set { throw new PlatformNotSupportedException (); }
}
public static bool IsErrorRedirected { get { throw new PlatformNotSupportedException (); } }
public static bool IsInputRedirected { get { throw new PlatformNotSupportedException (); } }
public static bool IsOutputRedirected { get { throw new PlatformNotSupportedException (); } }
public static void Beep () { throw new PlatformNotSupportedException (); }
public static void Beep (int frequency, int duration) { throw new PlatformNotSupportedException (); }
public static void Clear () { throw new PlatformNotSupportedException (); }
public static void MoveBufferArea (int sourceLeft, int sourceTop, int sourceWidth, int sourceHeight, int targetLeft, int targetTop) { throw new PlatformNotSupportedException(); }
public static void MoveBufferArea (int sourceLeft, int sourceTop, int sourceWidth, int sourceHeight, int targetLeft, int targetTop, char sourceChar, ConsoleColor sourceForeColor, ConsoleColor sourceBackColor) { throw new PlatformNotSupportedException(); }
public static ConsoleKeyInfo ReadKey ()
{
return ReadKey (false);
}
public static ConsoleKeyInfo ReadKey (bool intercept) { throw new PlatformNotSupportedException (); }
public static void ResetColor ()
{
lock (Console.Out) // synchronize with other writers
{
s_trackedForegroundColor = UnknownColor;
s_trackedBackgroundColor = UnknownColor;
}
}
public static void SetBufferSize (int width, int height) { throw new PlatformNotSupportedException (); }
public static void SetCursorPosition (int left, int top) { throw new PlatformNotSupportedException (); }
public static void SetWindowPosition (int left, int top) { throw new PlatformNotSupportedException (); }
public static void SetWindowSize (int width, int height) { throw new PlatformNotSupportedException (); }
public static event ConsoleCancelEventHandler CancelKeyPress {
add {
throw new PlatformNotSupportedException ();
}
remove {
throw new PlatformNotSupportedException ();
}
}
#endif
}
}

View File

@ -727,6 +727,69 @@ namespace MonoTests.System.Reflection.Emit
Assert.AreEqual ("foo", res [0][0]);
Assert.AreEqual ("bar", res [1][0]);
}
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
internal class NonVisibleCustomAttribute : Attribute
{
public NonVisibleCustomAttribute () {}
}
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
public class PublicVisibleCustomAttribute : Attribute
{
public PublicVisibleCustomAttribute () {}
}
private static void AddCustomClassAttribute (TypeBuilder typeBuilder, Type customAttrType)
{
var attribCtorParams = new Type[] {};
var attribCtorInfo = customAttrType.GetConstructor(attribCtorParams);
var attribBuilder = new CustomAttributeBuilder(attribCtorInfo, new object[] { });
typeBuilder.SetCustomAttribute(attribBuilder);
}
[Test]
public void NonvisibleCustomAttribute () {
//
// We build:
// [VisiblePublicCustom]
// [VisiblePublicCustom]
// [NonVisibleCustom]
// [VisiblePublicCustom]
// class BuiltType { public BuiltType () { } }
//
// And then we try to get all the attributes.
//
// Regression test for https://bugzilla.xamarin.com/show_bug.cgi?id=43291
var assemblyName = new AssemblyName("Repro43291Asm");
var assemblyBuilder = AssemblyBuilder.DefineDynamicAssembly(assemblyName, AssemblyBuilderAccess.Run);
var moduleBuilder = assemblyBuilder.DefineDynamicModule("Repro43291Mod");
var typeBuilder = moduleBuilder.DefineType("BuiltType",
TypeAttributes.Public | TypeAttributes.Class | TypeAttributes.BeforeFieldInit);
AddCustomClassAttribute (typeBuilder, typeof (PublicVisibleCustomAttribute));
AddCustomClassAttribute (typeBuilder, typeof (PublicVisibleCustomAttribute));
AddCustomClassAttribute (typeBuilder, typeof (NonVisibleCustomAttribute));
AddCustomClassAttribute (typeBuilder, typeof (PublicVisibleCustomAttribute));
var createdType = typeBuilder.CreateType ();
Assert.IsNotNull (createdType);
var obj = Activator.CreateInstance (createdType);
Assert.IsNotNull (obj);
var attrs = obj.GetType ().GetCustomAttributes (typeof (Attribute), true);
Assert.IsNotNull (attrs);
Assert.AreEqual (3, attrs.Length);
Assert.IsInstanceOfType (typeof (PublicVisibleCustomAttribute), attrs[0]);
Assert.IsInstanceOfType (typeof (PublicVisibleCustomAttribute), attrs[1]);
Assert.IsInstanceOfType (typeof (PublicVisibleCustomAttribute), attrs[2]);
}
}
}