Just checked and the latest versions of Gendarme and MoMA compile just
fine with this patch applied.

Thanks

On Jan 3, 9:28 pm, "Daniel Cazzulino" <[email protected]> wrote:
> This enables seamless integration with all the LINQ goodness, rather than
> being forced (and usually forgetting) to invoke collection.Cast<T> on all
> collections before using them in queries.
>
> I preserved the existing enumerators logic, basically just using the
> following pattern:
>
> - Existing enumerator (on some collections):
> public new IEnumerator GetEnumerator ()
> {
> return this.BaseGetAllValues ().GetEnumerator ();
>
> }
>
> - Replaced with:
> IEnumerator IEnumerable.GetEnumerator ()
> {
> return GetEnumerator();
>
> }
>
> public new IEnumerator<TypeReference> GetEnumerator()
> {
> foreach (var item in this.BaseGetAllValues())
> {
> yield return (TypeDefinition)item;
>
> }
> }
>
> This preserves the existing code that is using the non-generic enumerator
> (via "foreach") while exposing the new typed enumerator by default. If you
> think the visibility should be the other way around (public untyped
> enumerator and privately implemented typed enumerator) just let me know and
> I can make the change and submit a new patch.
>
> For classes directly inheriting from CollectionBase which didn't have a
> specialized enumerator, I simply added:
>
> public new IEnumerator<EventDefinition> GetEnumerator()
> {
> foreach (var item in this.List)
> {
> yield return (EventDefinition)item;
>
> }
> }
>
> Attached is the patch.
> I think all such collections should basically dissapear now that we have
> generics, but I didn't want to make the change bigger than needed. I just
> wanted the LINQ-enabled API, and IEnumerable<T> is the minimum requirement
> for it.
>
> Thanks!
>
> --
> Daniel Cazzulino | Developer Lead | XML MVP | Clarius Consulting | +1
> 425.329.3471
>
>  Mono.Cecil-all collections implement IEnumerable of T.patch
> 26KViewDownload
--~--~---------~--~----~------------~-------~--~----~
--
mono-cecil
-~----------~----~----~----~------~----~------~--~---

Reply via email to