blob: cf0615afa4202510cf38f8a6445e5f22b7c9d73f (
plain)
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
|
//
// This test is from Nigel Perry, Bugzilla #77060
//
// The issue here was that in the past we used to emit the
// Scope initialization on first use, which is wrong as illustrated
// in this test (the shared scope is not initialized for differnt
// code paths).
//
// This test is a running test, ensuring that it runs
//
#region Using directives
using System;
using System.Collections;
using System.Text;
using System.Timers;
#endregion
namespace Delegates
{ class Space
{ public int Value;
public delegate void DoCopy();
public DoCopy CopyIt;
public void Leak(bool useArray, int max)
{ DoCopy one = null;
if(useArray)
{
int[] work;
one = delegate
{ work = new int[max];
};
}
else
{
one = delegate { int xans = (max + 1) * max / 2; };
}
Console.WriteLine("Here goes...");
one();
Console.WriteLine("... made it");
}
}
class Program
{ static void SpaceLeak()
{ Space s = new Space();
Console.WriteLine(s.Value);
s.Leak(false, 1);
Console.WriteLine(s.Value);
}
public static void Main(string[] args)
{ SpaceLeak();
}
}
}
|