Re: [Mono-dev] corcompare patch for printing generic method type arguments
On Tue, 2005-10-25 at 06:05 +0900, Atsushi Eno wrote: Then it prints Foo[T(IFoo), U(IBar)] I prefer the syntax where will be more obvious that it is about generic possibly use same syntax as csc/gmcs use for error reporting. Something like `FooT(IFoo), U (IBar)' Hi, let's use the correct syntax here rather than inventing something new. Marek already came very close, but the correct syntax is Foo(IFoo) T, class U That's what ildasm uses. Martin ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list
Re: [Mono-dev] corcompare patch for printing generic method type arguments
Hi, Martin Baulig wrote: On Tue, 2005-10-25 at 06:05 +0900, Atsushi Eno wrote: Then it prints Foo[T(IFoo), U(IBar)] I prefer the syntax where will be more obvious that it is about generic possibly use same syntax as csc/gmcs use for error reporting. Something like `FooT(IFoo), U (IBar)' Hi, let's use the correct syntax here rather than inventing something new. Marek already came very close, but the correct syntax is Foo(IFoo) T, class U That's what ildasm uses. Just wondering, what should I print constraints for example below? where T : class, IFoo This change should be easy. I'll also include GenericTypeAttributes differences next time. Atsushi Eno ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list
Re: [Mono-dev] corcompare patch for printing generic method type arguments
On Wed, 2005-10-26 at 03:09 +0900, Atsushi Eno wrote: Just wondering, what should I print constraints for example below? where T : class, IFoo Hi, that's class (IFoo) T. This change should be easy. I'll also include GenericTypeAttributes differences next time. cool. Martin ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list
Re: [Mono-dev] corcompare patch for printing generic method type arguments
Hi, Hence, new patch. I also noticed that currently it does not differentiate abstract/ static/sealed (e.g. Foo() and static Foo()). It would be extraneous if we output MethodAttributes differences (there are commented lines) but it haven't been activated for a while. So, now it includes three changes: - generic parameter constraints on method names e.g. Foo() and FooT() are distinguished. - generic parameter attributes (actually it contains class and struct constraints. so they are duplicate) on both generic types and generic methods. - abstract/static/sealed signature on methods. Atsushi Eno Martin Baulig wrote: On Wed, 2005-10-26 at 03:09 +0900, Atsushi Eno wrote: Just wondering, what should I print constraints for example below? where T : class, IFoo Hi, that's class (IFoo) T. This change should be easy. I'll also include GenericTypeAttributes differences next time. cool. Martin Index: mono-api-diff.cs === --- mono-api-diff.cs(revision 52182) +++ mono-api-diff.cs(working copy) @@ -1182,8 +1182,27 @@ } } - class XMLGenericTypeConstraints : XMLNameGroup + abstract class XMLGenericGroup : XMLNameGroup { + string attributes; + + protected override void LoadExtraData (string name, XmlNode node) + { + attributes = ((XmlElement) node).GetAttribute (generic-attribute); + } + + protected override void CompareToInner (string name, XmlNode parent, XMLNameGroup other) + { + base.CompareToInner (name, parent, other); + + XMLGenericGroup g = (XMLGenericGroup) other; + if (attributes != g.attributes) + AddWarning (parent, Incorrect generic attributes: '{0}' != '{1}', attributes, g.attributes); + } + } + + class XMLGenericTypeConstraints : XMLGenericGroup + { public override string GroupName { get { return generic-type-constraints; } } @@ -1193,7 +1212,7 @@ } } - class XMLGenericMethodConstraints : XMLNameGroup + class XMLGenericMethodConstraints : XMLGenericGroup { public override string GroupName { get { return generic-method-constraints; } @@ -1581,7 +1600,17 @@ Hashtable returnTypes; Hashtable parameters; Hashtable genericConstraints; + Hashtable signatureFlags; + [Flags] + enum SignatureFlags + { + None = 0, + Abstract = 1, + Sealed = 2, + Static = 4 + } + protected override void LoadExtraData (string name, XmlNode node) { XmlAttribute xatt = node.Attributes [returntype]; @@ -1592,6 +1621,19 @@ returnTypes [name] = xatt.Value; } + SignatureFlags flags = SignatureFlags.None; + if (((XmlElement) node).GetAttribute (abstract) == true) + flags |= SignatureFlags.Abstract; + if (((XmlElement) node).GetAttribute (static) == true) + flags |= SignatureFlags.Static; + if (((XmlElement) node).GetAttribute (sealed) == true) + flags |= SignatureFlags.Sealed; + if (flags != SignatureFlags.None) { + if (signatureFlags == null) + signatureFlags = new Hashtable (); + signatureFlags [name] = flags; + } + XmlNode parametersNode = node.SelectSingleNode (parameters); if (parametersNode != null) { if (parameters == null) @@ -1625,6 +1667,19 @@ try { base.CompareToInner(name, parent, other); XMLMethods methods = (XMLMethods) other; + + SignatureFlags flags = signatureFlags != null + signatureFlags.ContainsKey (name) ? + (SignatureFlags) signatureFlags [name] : + SignatureFlags.None; + SignatureFlags oflags = methods.signatureFlags != null + methods.signatureFlags.ContainsKey (name) ? + (SignatureFlags)
[Mono-dev] corcompare patch for printing generic method type arguments
Hi, Here is another patch for corcompare for generics support. With this patch it prints type arguments in generic methods. Suppose that we have void FooT,U () where T : IFoo, U : IBar Then it prints Foo[T(IFoo), U(IBar)] Thanks to Martin for fixing bug #76482 (this patch works fine only after r52118). Atsushi Eno Index: mono-api-info.cs === --- mono-api-info.cs(revision 52122) +++ mono-api-info.cs(working copy) @@ -699,6 +699,28 @@ MethodBase method = (MethodBase) member; string name = method.Name; string parms = Parameters.GetSignature (method.GetParameters ()); + MethodInfo mi = method as MethodInfo; +#if NET_2_0 + Type [] genArgs = mi == null ? Type.EmptyTypes : + mi.GetGenericArguments (); + if (genArgs.Length 0) { + string [] genArgNames = new string [genArgs.Length]; + for (int i = 0; i genArgs.Length; i++) { + genArgNames [i] = genArgs [i].Name; + Type [] gcs = genArgs [i].GetGenericParameterConstraints (); + if (gcs.Length 0) { + string [] gcNames = new string [gcs.Length]; + for (int g = 0; g gcs.Length; g++) + gcNames [g] = gcs [g].FullName; + genArgNames [i] += String.Concat ( + (, + string.Join(, , gcNames), + )); + } + } + return String.Format ({0}[{2}]({1}), name, parms, string.Join (,, genArgNames)); + } +#endif return String.Format ({0}({1}), name, parms); } ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list
Re: [Mono-dev] corcompare patch for printing generic method type arguments
Hi Marek, Marek Safar wrote: Hello Eno, Here is another patch for corcompare for generics support. With this patch it prints type arguments in generic methods. Suppose that we have void FooT,U () where T : IFoo, U : IBar Then it prints Foo[T(IFoo), U(IBar)] I prefer the syntax where will be more obvious that it is about generic possibly use same syntax as csc/gmcs use for error reporting. Something like `FooT(IFoo), U (IBar)' Oh, true. Well, then we could just make it just to print where, so void FooT,U () where T : IFoo, U : IBar becomes void FooT,U () where T : IFoo, U : IBar as is ;-) I attached the updated patch. Atsushi Eno Index: mono-api-info.cs === --- mono-api-info.cs(revision 52138) +++ mono-api-info.cs(working copy) @@ -699,6 +699,34 @@ MethodBase method = (MethodBase) member; string name = method.Name; string parms = Parameters.GetSignature (method.GetParameters ()); + MethodInfo mi = method as MethodInfo; +#if NET_2_0 + Type [] genArgs = mi == null ? Type.EmptyTypes : + mi.GetGenericArguments (); + if (genArgs.Length 0) { + string [] genArgNames = new string [genArgs.Length]; + string genArgCsts = String.Empty; + for (int i = 0; i genArgs.Length; i++) { + genArgNames [i] = genArgs [i].Name; + Type [] gcs = genArgs [i].GetGenericParameterConstraints (); + if (gcs.Length 0) { + string [] gcNames = new string [gcs.Length]; + for (int g = 0; g gcs.Length; g++) + gcNames [g] = gcs [g].FullName; + genArgCsts += String.Concat ( + genArgNames [i], +: , + string.Join (, , gcNames)); + } + } + return String.Format ({0}{2}({1}){3}, + name, + parms, + string.Join (,, genArgNames), + genArgCsts.Length == 0 ? String.Empty : +where + genArgCsts); + } +#endif return String.Format ({0}({1}), name, parms); } ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list