forked from dotnet/source-indexer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClass1.cs
More file actions
186 lines (154 loc) · 3.34 KB
/
Class1.cs
File metadata and controls
186 lines (154 loc) · 3.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.InteropServices;
public static class Extensions
{
public static string NewLine => "\r\n";
public static void ExtensionMethod(this string s)
{
var s1 = new string(new char[0]);
var s2 = new string(' ', 42);
}
}
#if TESTDEFINE
public class ThisShouldBeEnabled { }
#endif
class ArrayOfZeroLengthAllocationDetection
{
private const int SIZE = 0;
static void Test()
{
var a = new object[0];
Console.WriteLine(a.Length);
a = new object[] { };
Console.WriteLine(a.Length);
a = new object[SIZE];
}
}
public class ExtensionUsage
{
public void Test()
{
"".ExtensionMethod();
Extensions.ExtensionMethod("");
}
~ExtensionUsage()
{
}
}
public interface I1 { void Foo(); }
public interface I2 : I1 { }
interface I3 : IEnumerable<I2>, I2, I1 { }
interface I4 : IEnumerable<I2> { }
public partial class Partial
{
partial void Foo();
internal const string Internal = "Friend";
}
namespace Acme
{
public class Generic<T>
{
public static T M<T>(T t) { }
}
namespace Test
{
}
namespace Test2 { class Baz { } }
}
[Guid(@"C09FBDCB-C126-4A4F-BF36-4B1E3AF4D376")]
class Class<U> : I1
{
public class Nested1
{
public enum Nested2
{
A
}
}
public class NestedGeneric<T>
{
public T GetT(U u) { throw null; }
}
void I1.Foo()
{
#if _DEBUG
whatnot
#endif
C c = new C();
throw new NotImplementedException();
}
}
[Guid("C09FBDCB-C126-4A4F-BF36-4B1E3AF4D376")]
class Abc : I1
{
public virtual void M() { }
protected virtual string Name { get; set; }
protected internal virtual event Action Event;
public static readonly Guid guid = new Guid(@"AAAAAAAA-C126-4A4F-BF36-4B1E3AF4D376");
public static readonly Guid guid2 = new Guid("{BBBBBBBB-C126-4A4F-BF36-4B1E3AF4D376}");
public static readonly Guid guid3 = new Guid(@"{C09FBDCB-C126-4A4F-bf36-4B1E3AF4D376}");
public void Foo()
{
var a = Name;
Name = a;
this.Name = a;
}
}
class A
{
public virtual void M()
{
}
public abstract string Name
{
get;
}
protected virtual event Action Event;
}
class B : A, System.ICloneable
{
System.ICloneable c;
A a = new A();
public B()
{
}
public override void M()
{
base.M();
Name = Name;
var b = new B();
}
public object Clone()
{
throw new NotImplementedException();
}
public override string Name
{
get
{
return base.Name;
}
}
protected internal override event Action Event;
}
class TargetedTypeNewTest
{
public TargetedTypeNewTest(B b) { }
static TargetedTypeNewTest Create()
{
return new(new());
}
}
class TypeWithPrimaryConstructor(A a, B b)
{
public A A => a;
public B[] ArrayOfB => [b];
}
class EmptyType;
class TypeWithAllowsRefStruct<T>
where T : allows ref struct
{
public static T Return(T value) => value;
}