}
}
+ public void SetOwner (Attributable owner)
+ {
+ targets [0] = owner;
+ }
+
/// <summary>
/// Tries to resolve the type of the attribute. Flags an error if it can't, and complain is true.
/// </summary>
Attrs.AddRange (attrs);
}
+ public static void AttachFromPartial (Attributable target, Attributable partialSrc)
+ {
+ if (target.OptAttributes == null) {
+ target.OptAttributes = partialSrc.OptAttributes;
+ } else {
+ target.OptAttributes.Attrs.AddRange (partialSrc.OptAttributes.Attrs);
+ }
+
+ foreach (var attr in partialSrc.OptAttributes.Attrs) {
+ attr.SetOwner (target);
+ }
+ }
+
public void AttachTo (Attributable attributable, IMemberContext context)
{
foreach (Attribute a in Attrs)
--- /dev/null
+using System;
+using CustomAttributes;
+
+partial class A
+{
+ // Partial methods w/o attributes.
+ partial void PartialMethodWith_NoAttr_NoDefn(string s);
+ partial void PartialMethodWith_NoAttr_Decl(string s);
+
+ // Partial methods w/o a definition.
+ [AttributeA("ANoDef")]
+ partial void PartialMethodWith_AAttr_NoDefn(string s);
+ partial void PartialMethodWith_BAttr_NoDefn([AttributeB("BNoDef")]string s);
+
+ // Attributes only on declaration.
+ [AttributeA("ADecl")]
+ partial void PartialMethodWith_AAttr_Decl(string s);
+ partial void PartialMethodWith_BAttr_Decl([AttributeB("BDecl")]string s);
+
+ // Attributes only on definition.
+ partial void PartialMethodWith_AAttr_Defn(string s);
+ partial void PartialMethodWith_BAttr_Defn(string s);
+
+ // Different Attribute on definition.
+ [AttributeA("WithABAttr")]
+ partial void PartialMethodWith_ABAttr(string s);
+ partial void PartialMethodWith_BAAttr([AttributeB("WithBAAttr")]string s);
+}
+
+partial class A
+{
+ // Partial methods w/o attributes.
+ partial void PartialMethodWith_NoAttr_Decl(string s) { }
+
+ // Attributes only on declaration.
+ partial void PartialMethodWith_AAttr_Decl(string s) { }
+ partial void PartialMethodWith_BAttr_Decl(string s) { }
+
+ // Attributes only on definition.
+ [AttributeA("ADefn")]
+ partial void PartialMethodWith_AAttr_Defn(string s) { }
+ partial void PartialMethodWith_BAttr_Defn([AttributeB("BDefn")]string s)
+ {
+ }
+
+ // Different Attribute on definition.
+ [AttributeB("ABAttr")]
+ partial void PartialMethodWith_ABAttr(string s) { }
+ partial void PartialMethodWith_BAAttr([AttributeA("BAAttr")]string s) { }
+}
+
+namespace CustomAttributes {
+ [AttributeUsage(AttributeTargets.All, AllowMultiple=true)]
+ public class AttributeA : Attribute {
+ public AttributeA(String a) {}
+ }
+
+ [AttributeUsage(AttributeTargets.All, AllowMultiple=true)]
+ public class AttributeB : Attribute {
+ public AttributeB(String a) {}
+ }
+}
+
+class X
+{
+ public static void Main ()
+ {
+ }
+}
\ No newline at end of file
</method>
</type>
</test>
+ <test name="test-partial-34.cs">
+ <type name="A">
+ <method name="Void PartialMethodWith_NoAttr_Decl(System.String)" attrs="129">
+ <size>2</size>
+ </method>
+ <method name="Void PartialMethodWith_AAttr_Decl(System.String)" attrs="129">
+ <size>2</size>
+ </method>
+ <method name="Void PartialMethodWith_BAttr_Decl(System.String)" attrs="129">
+ <size>2</size>
+ </method>
+ <method name="Void PartialMethodWith_AAttr_Defn(System.String)" attrs="129">
+ <size>2</size>
+ </method>
+ <method name="Void PartialMethodWith_BAttr_Defn(System.String)" attrs="129">
+ <size>2</size>
+ </method>
+ <method name="Void PartialMethodWith_ABAttr(System.String)" attrs="129">
+ <size>2</size>
+ </method>
+ <method name="Void PartialMethodWith_BAAttr(System.String)" attrs="129">
+ <size>2</size>
+ </method>
+ <method name="Void .ctor()" attrs="6278">
+ <size>7</size>
+ </method>
+ </type>
+ <type name="CustomAttributes.AttributeA">
+ <method name="Void .ctor(String)" attrs="6278">
+ <size>8</size>
+ </method>
+ </type>
+ <type name="CustomAttributes.AttributeB">
+ <method name="Void .ctor(String)" attrs="6278">
+ <size>8</size>
+ </method>
+ </type>
+ <type name="X">
+ <method name="Void Main()" attrs="150">
+ <size>2</size>
+ </method>
+ <method name="Void .ctor()" attrs="6278">
+ <size>7</size>
+ </method>
+ </type>
+ </test>
<test name="test-pattern-01.cs">
<type name="TypePattern">
<method name="Int32 Main()" attrs="150">