Debian Codegraph @

mcs/class/referencesource/mscorlib/system/collections/generic/ienumerable.cs

raw
1 // ==++==
2 //
3 // Copyright (c) Microsoft Corporation. All rights reserved.
4 //
5 // ==--==
6 /*============================================================
7 **
8 ** Interface: IEnumerable
9 **
10 ** <OWNER>kimhamil</OWNER>
11 **
12 **
13 ** Purpose: Interface for providing generic IEnumerators
14 **
15 **
16 ===========================================================*/
17 namespace System.Collections.Generic {
18 using System;
19 using System.Collections;
20 using System.Runtime.InteropServices;
21 using System.Runtime.CompilerServices;
22 using System.Diagnostics.Contracts;
23
24 // Implement this interface if you need to support foreach semantics.
25
26 // Note that T[] : IList<T>, and we want to ensure that if you use
27 // IList<YourValueType>, we ensure a YourValueType[] can be used
28 // without jitting. Hence the TypeDependencyAttribute on SZArrayHelper.
29 // This is a special hack internally though - see VM\compile.cpp.
30 // The same attribute is on IList<T> and ICollection<T>.
31 [TypeDependencyAttribute("System.SZArrayHelper")]
32 #if CONTRACTS_FULL
33 [ContractClass(typeof(IEnumerableContract<>))]
34 #endif // CONTRACTS_FULL
35 public interface IEnumerable<out T> : IEnumerable
36 {
37 // Returns an IEnumerator for this enumerable Object. The enumerator provides
38 // a simple way to access all the contents of a collection.
39 /// <include file='doc\IEnumerable.uex' path='docs/doc[@for="IEnumerable.GetEnumerator"]/*' />
40 new IEnumerator<T> GetEnumerator();
41 }
42
43 #if CONTRACTS_FULL
44 [ContractClassFor(typeof(IEnumerable<>))]
45 internal abstract class IEnumerableContract<T> : IEnumerable<T>
46 {
47 [Pure]
48 IEnumerator<T> IEnumerable<T>.GetEnumerator()
49 {
50 Contract.Ensures(Contract.Result<IEnumerator<T>>() != null);
51 return default(IEnumerator<T>);
52 }
53
54 IEnumerator IEnumerable.GetEnumerator()
55 {
56 return default(IEnumerator);
57 }
58 }
59 #endif // CONTRACTS_FULL
60 }