Skip to content

Commit 43a1953

Browse files
authored
Merge pull request #1013 from mjbvz/use-readonly-members-for-debug-records
Use readonly members for debugger record types
2 parents c497e3c + 80e6090 commit 43a1953

11 files changed

+46
-172
lines changed

Nodejs/Product/Nodejs/Debugger/BreakpointBindingEventArgs.cs

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,13 @@
1717
using System;
1818

1919
namespace Microsoft.NodejsTools.Debugger {
20-
class BreakpointBindingEventArgs : EventArgs {
21-
private readonly NodeBreakpoint _breakpoint;
22-
private readonly NodeBreakpointBinding _breakpointBinding;
20+
sealed class BreakpointBindingEventArgs : EventArgs {
21+
public readonly NodeBreakpoint Breakpoint;
22+
public readonly NodeBreakpointBinding BreakpointBinding;
2323

2424
public BreakpointBindingEventArgs(NodeBreakpoint breakpoint, NodeBreakpointBinding breakpointBinding) {
25-
_breakpoint = breakpoint;
26-
_breakpointBinding = breakpointBinding;
27-
}
28-
29-
public NodeBreakpoint Breakpoint {
30-
get {
31-
return _breakpoint;
32-
}
33-
}
34-
35-
public NodeBreakpointBinding BreakpointBinding {
36-
get {
37-
return _breakpointBinding;
38-
}
25+
Breakpoint = breakpoint;
26+
BreakpointBinding = breakpointBinding;
3927
}
4028
}
4129
}

Nodejs/Product/Nodejs/Debugger/BreakpointHitEventArgs.cs

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,13 @@
1717
using System;
1818

1919
namespace Microsoft.NodejsTools.Debugger {
20-
class BreakpointHitEventArgs : EventArgs {
21-
private readonly NodeBreakpointBinding _breakpointBinding;
22-
private readonly NodeThread _thread;
20+
sealed class BreakpointHitEventArgs : EventArgs {
21+
public readonly NodeBreakpointBinding BreakpointBinding;
22+
public readonly NodeThread Thread;
2323

2424
public BreakpointHitEventArgs(NodeBreakpointBinding breakpoint, NodeThread thread) {
25-
_breakpointBinding = breakpoint;
26-
_thread = thread;
27-
}
28-
29-
public NodeBreakpointBinding BreakpointBinding {
30-
get {
31-
return _breakpointBinding;
32-
}
33-
}
34-
35-
public NodeThread Thread {
36-
get {
37-
return _thread;
38-
}
25+
BreakpointBinding = breakpoint;
26+
Thread = thread;
3927
}
4028
}
4129
}

Nodejs/Product/Nodejs/Debugger/ExceptionRaisedEventArgs.cs

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,32 +18,14 @@
1818

1919
namespace Microsoft.NodejsTools.Debugger {
2020
class ExceptionRaisedEventArgs : EventArgs {
21-
private readonly NodeException _exception;
22-
private readonly NodeThread _thread;
23-
private readonly bool _isUnhandled;
21+
public readonly NodeThread Thread;
22+
public readonly NodeException Exception;
23+
public readonly bool IsUnhandled;
2424

2525
public ExceptionRaisedEventArgs(NodeThread thread, NodeException exception, bool isUnhandled) {
26-
_thread = thread;
27-
_exception = exception;
28-
_isUnhandled = isUnhandled;
29-
}
30-
31-
public NodeException Exception {
32-
get {
33-
return _exception;
34-
}
35-
}
36-
37-
public NodeThread Thread {
38-
get {
39-
return _thread;
40-
}
41-
}
42-
43-
public bool IsUnhandled {
44-
get {
45-
return _isUnhandled;
46-
}
26+
Thread = thread;
27+
Exception = exception;
28+
IsUnhandled = isUnhandled;
4729
}
4830
}
4931
}

Nodejs/Product/Nodejs/Debugger/FilePosition.cs

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -19,35 +19,14 @@ namespace Microsoft.NodejsTools.Debugger {
1919
/// Stores line and column position in the file.
2020
/// </summary>
2121
sealed class FilePosition {
22-
private readonly int _column;
23-
private readonly string _fileName;
24-
private readonly int _line;
22+
public readonly int Column;
23+
public readonly string FileName;
24+
public readonly int Line;
2525

2626
public FilePosition(string fileName, int line, int column) {
27-
_fileName = fileName;
28-
_line = line;
29-
_column = column;
30-
}
31-
32-
/// <summary>
33-
/// Gets a file name.
34-
/// </summary>
35-
public string FileName {
36-
get { return _fileName; }
37-
}
38-
39-
/// <summary>
40-
/// Gets a line number.
41-
/// </summary>
42-
public int Line {
43-
get { return _line; }
44-
}
45-
46-
/// <summary>
47-
/// Gets a column number.
48-
/// </summary>
49-
public int Column {
50-
get { return _column; }
27+
FileName = fileName;
28+
Line = line;
29+
Column = column;
5130
}
5231
}
5332
}

Nodejs/Product/Nodejs/Debugger/ModuleLoadedEventArgs.cs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,11 @@
1717
using System;
1818

1919
namespace Microsoft.NodejsTools.Debugger {
20-
class ModuleLoadedEventArgs : EventArgs {
21-
private readonly NodeModule _module;
20+
sealed class ModuleLoadedEventArgs : EventArgs {
21+
public readonly NodeModule Module;
2222

2323
public ModuleLoadedEventArgs(NodeModule module) {
24-
_module = module;
25-
}
26-
27-
public NodeModule Module {
28-
get {
29-
return _module;
30-
}
24+
Module = module;
3125
}
3226
}
3327
}

Nodejs/Product/Nodejs/Debugger/NodeEventEventArgs.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,10 @@
1919

2020
namespace Microsoft.NodejsTools.Debugger {
2121
sealed class NodeEventEventArgs : EventArgs {
22-
private readonly Dictionary<string, object> _data;
22+
public readonly Dictionary<string, object> Data;
2323

2424
public NodeEventEventArgs(Dictionary<string, object> data) {
25-
_data = data;
26-
}
27-
28-
public Dictionary<string, object> Data {
29-
get { return _data; }
25+
Data = data;
3026
}
3127
}
3228
}

Nodejs/Product/Nodejs/Debugger/NodeException.cs

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,13 @@
1414
//
1515
//*********************************************************//
1616

17-
1817
namespace Microsoft.NodejsTools.Debugger {
19-
class NodeException {
20-
private readonly string _typeName, _description;
18+
sealed class NodeException {
19+
public readonly string TypeName, Description;
2120

2221
public NodeException(string typeName, string description) {
23-
_typeName = typeName;
24-
_description = description;
25-
}
26-
27-
public string TypeName {
28-
get {
29-
return _typeName;
30-
}
31-
}
32-
33-
public string Description {
34-
get {
35-
return _description;
36-
}
22+
TypeName = typeName;
23+
Description = description;
3724
}
3825
}
3926
}

Nodejs/Product/Nodejs/Debugger/NodeThread.cs

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,16 @@
1717
using System.Collections.Generic;
1818

1919
namespace Microsoft.NodejsTools.Debugger {
20-
class NodeThread {
20+
sealed class NodeThread {
2121
private readonly int _identity;
2222
private readonly NodeDebugger _process;
2323
private readonly bool _isWorkerThread;
24-
private string _name;
25-
private IList<NodeStackFrame> _frames;
2624

2725
internal NodeThread(NodeDebugger process, int identity, bool isWorkerThread) {
2826
_process = process;
2927
_identity = identity;
3028
_isWorkerThread = isWorkerThread;
31-
_name = "main thread";
29+
Name = "main thread";
3230
}
3331

3432
public void StepInto() {
@@ -57,24 +55,17 @@ internal void ClearSteppingState() {
5755
_process.SendClearStepping(_identity);
5856
}
5957

60-
public IList<NodeStackFrame> Frames {
61-
get {
62-
return _frames;
63-
}
64-
set {
65-
_frames = value;
66-
}
67-
}
58+
public IList<NodeStackFrame> Frames { get; set; }
6859

6960
public int CallstackDepth {
7061
get {
71-
return _frames != null ? _frames.Count : 0;
62+
return Frames != null ? Frames.Count : 0;
7263
}
7364
}
7465

7566
public NodeStackFrame TopStackFrame {
7667
get {
77-
return _frames != null && _frames.Count > 0 ? _frames[0] : null;
68+
return Frames != null && Frames.Count > 0 ? Frames[0] : null;
7869
}
7970
}
8071

@@ -84,14 +75,7 @@ public NodeDebugger Process {
8475
}
8576
}
8677

87-
public string Name {
88-
get {
89-
return _name;
90-
}
91-
set {
92-
_name = value;
93-
}
94-
}
78+
public string Name { get; set; }
9579

9680
internal int Id {
9781
get {

Nodejs/Product/Nodejs/Debugger/OutputEventArgs.cs

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,12 @@
1818

1919
namespace Microsoft.NodejsTools.Debugger {
2020
sealed class OutputEventArgs : EventArgs {
21-
private readonly string _output;
22-
private readonly NodeThread _thread;
21+
public readonly NodeThread Thread;
22+
public readonly string Output;
2323

2424
public OutputEventArgs(NodeThread thread, string output) {
25-
_thread = thread;
26-
_output = output;
27-
}
28-
29-
public NodeThread Thread {
30-
get {
31-
return _thread;
32-
}
33-
}
34-
35-
public string Output {
36-
get {
37-
return _output;
38-
}
25+
Thread = thread;
26+
Output = output;
3927
}
4028
}
4129
}

Nodejs/Product/Nodejs/Debugger/ProcessExitedEventArgs.cs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,11 @@
1717
using System;
1818

1919
namespace Microsoft.NodejsTools.Debugger {
20-
class ProcessExitedEventArgs : EventArgs {
21-
private readonly int _exitCode;
20+
sealed class ProcessExitedEventArgs : EventArgs {
21+
public readonly int ExitCode;
2222

2323
public ProcessExitedEventArgs(int exitCode) {
24-
_exitCode = exitCode;
25-
}
26-
27-
public int ExitCode {
28-
get {
29-
return _exitCode;
30-
}
24+
ExitCode = exitCode;
3125
}
3226
}
3327
}

0 commit comments

Comments
 (0)