--- /dev/null
+// CS0579: The attribute `TestAttributesCollecting.A' cannot be applied multiple times
+// Line: 19
+
+using System;
+
+namespace TestAttributesCollecting
+{
+ class A : Attribute
+ {
+ public A (int a)
+ {
+ }
+ }
+
+ partial class G1<[A (1)]T>
+ {
+ }
+
+ partial class G1<[A (2)]T>
+ {
+ }
+}
protected virtual bool DoResolveTypeParameters ()
{
- var tparams = CurrentTypeParameters;
+ var tparams = MemberName.TypeParameters;
if (tparams == null)
return true;
error = true;
return false;
}
+
+ if (IsPartialPart) {
+ var pc_tp = PartialContainer.CurrentTypeParameters [i];
+
+ tp.Create (spec, this);
+ tp.Define (pc_tp);
+
+ if (tp.OptAttributes != null) {
+ if (pc_tp.OptAttributes == null)
+ pc_tp.OptAttributes = tp.OptAttributes;
+ else
+ pc_tp.OptAttributes.Attrs.AddRange (tp.OptAttributes.Attrs);
+ }
+ }
}
if (IsPartialPart) {
spec.SetMetaInfo (type);
}
+ public void Define (TypeParameter tp)
+ {
+ builder = tp.builder;
+ }
+
public void EmitConstraints (GenericTypeParameterBuilder builder)
{
var attr = GenericParameterAttributes.None;
if (IsPartialDefinition) {
if (partialMethodImplementation != null && CurrentTypeParameters != null) {
CurrentTypeParameters.CheckPartialConstraints (partialMethodImplementation);
+
+ var otp = partialMethodImplementation.CurrentTypeParameters;
+ for (int i = 0; i < CurrentTypeParameters.Count; ++i) {
+ var tp = CurrentTypeParameters [i];
+ tp.Define (otp[i]);
+ }
}
return;
// Ensure we are always using method declaration parameters
for (int i = 0; i < methodDefinition.parameters.Count; ++i ) {
- parameters [i].Name = methodDefinition.parameters [i].Name;
- parameters [i].DefaultValue = methodDefinition.parameters [i].DefaultValue;
+ var md_p = methodDefinition.parameters [i];
+ var p = parameters [i];
+ p.Name = md_p.Name;
+ p.DefaultValue = md_p.DefaultValue;
+ if (md_p.OptAttributes != null) {
+ if (p.OptAttributes == null) {
+ p.OptAttributes = md_p.OptAttributes;
+ } else {
+ p.OptAttributes.Attrs.AddRange (md_p.OptAttributes.Attrs);
+ }
+ }
}
- if (methodDefinition.attributes == null)
- return;
+ if (methodDefinition.attributes != null) {
+ if (attributes == null) {
+ attributes = methodDefinition.attributes;
+ } else {
+ attributes.Attrs.AddRange (methodDefinition.attributes.Attrs);
+ }
+ }
- if (attributes == null) {
- attributes = methodDefinition.attributes;
- } else {
- attributes.Attrs.AddRange (methodDefinition.attributes.Attrs);
+ if (CurrentTypeParameters != null) {
+ for (int i = 0; i < CurrentTypeParameters.Count; ++i) {
+ var tp_other = methodDefinition.CurrentTypeParameters [i];
+ if (tp_other.OptAttributes == null)
+ continue;
+
+ var tp = CurrentTypeParameters [i];
+ if (tp.OptAttributes == null) {
+ tp.OptAttributes = tp_other.OptAttributes;
+ } else {
+ tp.OptAttributes.Attrs.AddRange (tp.OptAttributes.Attrs);
+ }
+ }
}
}
}
using System;
-namespace ConsoleApplication1
+namespace TestAttributesCollecting
{
+ class A : Attribute
+ {
+ }
+
public partial class X
{
- [CLSCompliant (true)]
- partial void Foo ();
+ [A]
+ partial void Foo<[A] T>(/*[A]*/ int p);
}
public partial class X
{
- partial void Foo ()
+ partial void Foo<T> (int p)
{
int i;
}
}
-
+
public partial class Y
{
partial void Foo ()
int i;
}
}
-
+
public partial class Y
{
[CLSCompliant (true)]
{
public static int Main ()
{
- var x = typeof (X).GetMethod ("Foo", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).GetCustomAttributes (true);
+ var m = typeof (X).GetMethod ("Foo", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
+ var x = m.GetCustomAttributes (true);
Console.WriteLine (x.Length);
if (x.Length != 1)
return 1;
+ var ga = m.GetGenericArguments ();
+ x = ga [0].GetCustomAttributes (false);
+ if (x.Length != 1)
+ return 2;
+
x = typeof (Y).GetMethod ("Foo", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).GetCustomAttributes (true);
Console.WriteLine (x.Length);
if (x.Length != 1)
- return 2;
-
+ return 3;
+
return 0;
}
}
</type>\r
</test>\r
<test name="test-partial-26.cs">\r
- <type name="ConsoleApplication1.X">\r
- <method name="Void Foo()" attrs="129">\r
+ <type name="TestAttributesCollecting.A">\r
+ <method name="Void .ctor()" attrs="6278">\r
+ <size>7</size>\r
+ </method>\r
+ </type>\r
+ <type name="TestAttributesCollecting.X">\r
+ <method name="Void Foo[T](Int32)" attrs="129">\r
<size>2</size>\r
</method>\r
<method name="Void .ctor()" attrs="6278">\r
<size>7</size>\r
</method>\r
</type>\r
- <type name="ConsoleApplication1.Y">\r
+ <type name="TestAttributesCollecting.Y">\r
<method name="Void Foo()" attrs="129">\r
<size>2</size>\r
</method>\r
<size>7</size>\r
</method>\r
</type>\r
- <type name="ConsoleApplication1.Program">\r
+ <type name="TestAttributesCollecting.Program">\r
<method name="Int32 Main()" attrs="150">\r
- <size>116</size>\r
+ <size>151</size>\r
</method>\r
<method name="Void .ctor()" attrs="6278">\r
<size>7</size>\r