//
using System.Collections;
+using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System;
using System.Security;
return type.GUID;
}
- [MonoTODO]
public static string GenerateProgIdForType (Type type)
{
- throw new NotImplementedException ();
+ IList<CustomAttributeData> attrs = CustomAttributeData.GetCustomAttributes (type);
+
+ foreach (var a in attrs)
+ {
+ var dt = a.Constructor.DeclaringType;
+ string name = dt.Name;
+ if (name == "ProgIdAttribute")
+ {
+ var args = a.ConstructorArguments;
+ string text = a.ConstructorArguments[0].Value as string;
+ if (text == null)
+ {
+ text = string.Empty;
+ }
+ return text;
+ }
+ }
+
+ return type.FullName;
}
[MonoTODO]
}
}
+ [Test]
+ public void TestGenerateProgIdForType()
+ {
+ string output;
+
+ output = Marshal.GenerateProgIdForType(typeof(TestCoClass));
+ Assert.AreEqual ("MonoTests.System.Runtime.InteropServices.TestCoClass", output, "#1");
+
+ output = Marshal.GenerateProgIdForType(typeof(TestCoClassWithProgId));
+ Assert.AreEqual ("CoClassWithProgId", output, "#2");
+ }
+
[Test]
public void TestGlobalAlloc ()
{
{
}
}
+
+ [ProgId("CoClassWithProgId")]
+ public class TestCoClassWithProgId : ITestDispatch
+ {
+ public void DoNothing ()
+ {
+ }
+ }
}
#endif