Skip to content

Commit 735bc29

Browse files
Records and init only properties (#442)
Made all lsp/dap models records where appropraite. for lsp registration options and capabilities are not records and do not have init only properties. These values can be adjusted during the startup lifecycle. +semver:minor
1 parent e340fbe commit 735bc29

File tree

311 files changed

+2074
-2182
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

311 files changed

+2074
-2182
lines changed

sample/SampleServer/TextDocumentHandler.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ public override Task<Unit> Handle(DidCloseTextDocumentParams notification, Cance
6969

7070
protected override TextDocumentSyncRegistrationOptions CreateRegistrationOptions(SynchronizationCapability capability, ClientCapabilities clientCapabilities) => new TextDocumentSyncRegistrationOptions() {
7171
DocumentSelector = _documentSelector,
72-
SyncKind = Change,
73-
IncludeText = true
72+
Change = Change,
73+
Save = new SaveOptions() { IncludeText = true }
7474
};
7575

7676
public override TextDocumentAttributes GetTextDocumentAttributes(DocumentUri uri) => new TextDocumentAttributes(uri, "csharp");

src/Dap.Protocol/Feature/Events/BreakpointFeature.cs

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,71 +11,70 @@ namespace OmniSharp.Extensions.DebugAdapter.Protocol
1111
{
1212
namespace Models
1313
{
14-
1514
/// <summary>
1615
/// Information about a Breakpoint created in setBreakpoints or setFunctionBreakpoints.
1716
/// </summary>
18-
public class Breakpoint
17+
public record Breakpoint
1918
{
2019
/// <summary>
2120
/// An optional identifier for the breakpoint. It is needed if breakpoint events are used to update or remove breakpoints.
2221
/// </summary>
2322
[Optional]
24-
public long? Id { get; set; }
23+
public long? Id { get; init; }
2524

2625
/// <summary>
2726
/// If true breakpoint could be set (but not necessarily at the desired location).
2827
/// </summary>
29-
public bool Verified { get; set; }
28+
public bool Verified { get; init; }
3029

3130
/// <summary>
3231
/// An optional message about the state of the breakpoint. This is shown to the user and can be used to explain why a breakpoint could not be verified.
3332
/// </summary>
3433
[Optional]
35-
public string? Message { get; set; }
34+
public string? Message { get; init; }
3635

3736
/// <summary>
3837
/// The source where the breakpoint is located.
3938
/// </summary>
4039
[Optional]
41-
public Source? Source { get; set; }
40+
public Source? Source { get; init; }
4241

4342
/// <summary>
4443
/// The start line of the actual range covered by the breakpoint.
4544
/// </summary>
4645
[Optional]
47-
public int? Line { get; set; }
46+
public int? Line { get; init; }
4847

4948
/// <summary>
5049
/// An optional start column of the actual range covered by the breakpoint.
5150
/// </summary>
5251
[Optional]
53-
public int? Column { get; set; }
52+
public int? Column { get; init; }
5453

5554
/// <summary>
5655
/// An optional end line of the actual range covered by the breakpoint.
5756
/// </summary>
5857
[Optional]
59-
public int? EndLine { get; set; }
58+
public int? EndLine { get; init; }
6059

6160
/// <summary>
6261
/// An optional end column of the actual range covered by the breakpoint. If no end line is given, then the end column is assumed to be in the start line.
6362
/// </summary>
6463
[Optional]
65-
public int? EndColumn { get; set; }
64+
public int? EndColumn { get; init; }
6665

6766
/// <summary>
6867
/// An optional memory reference to where the breakpoint is set.
6968
/// </summary>
7069
[Optional]
71-
public string? InstructionReference { get; set; }
70+
public string? InstructionReference { get; init; }
7271

7372
/// <summary>
7473
/// An optional offset from the instruction reference.
7574
/// This can be negative.
7675
/// </summary>
7776
[Optional]
78-
public int? Offset { get; set; }
77+
public int? Offset { get; init; }
7978
}
8079
}
8180
namespace Events
@@ -87,18 +86,18 @@ namespace Events
8786
GenerateHandlerMethods,
8887
GenerateRequestMethods
8988
]
90-
public class BreakpointEvent : IRequest
89+
public record BreakpointEvent : IRequest
9190
{
9291
/// <summary>
9392
/// The reason for the event.
9493
/// Values: 'changed', 'new', 'removed', etc.
9594
/// </summary>
96-
public string Reason { get; set; } = null!;
95+
public string Reason { get; init; }
9796

9897
/// <summary>
9998
/// The 'id' attribute is used to find the target breakpoint and the other attributes are used as the new values.
10099
/// </summary>
101-
public Breakpoint Breakpoint { get; set; } = null!;
100+
public Breakpoint Breakpoint { get; init; }
102101
}
103102
}
104103
}

src/Dap.Protocol/Feature/Events/CapabilitiesFeature.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace Models
1414
/// <summary>
1515
/// Information about the capabilities of a debug adapter.
1616
/// </summary>
17-
public class Capabilities
17+
public record Capabilities
1818
{
1919
/// <summary>
2020
/// The debug adapter supports the 'configurationDone' request.
@@ -232,12 +232,12 @@ namespace Events
232232
GenerateHandlerMethods,
233233
GenerateRequestMethods
234234
]
235-
public class CapabilitiesEvent : IRequest
235+
public record CapabilitiesEvent : IRequest
236236
{
237237
/// <summary>
238238
/// The set of updated capabilities.
239239
/// </summary>
240-
public Capabilities Capabilities { get; set; } = null!;
240+
public Capabilities Capabilities { get; init; }
241241
}
242242
}
243243
}

src/Dap.Protocol/Feature/Events/ContinuedFeature.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,18 @@ namespace Events
1717
GenerateHandlerMethods,
1818
GenerateRequestMethods
1919
]
20-
public class ContinuedEvent : IRequest
20+
public record ContinuedEvent : IRequest
2121
{
2222
/// <summary>
2323
/// The thread which was continued.
2424
/// </summary>
25-
public long ThreadId { get; set; }
25+
public long ThreadId { get; init; }
2626

2727
/// <summary>
2828
/// If 'allThreadsContinued' is true, a debug adapter can announce that all threads have continued.
2929
/// </summary>
3030
[Optional]
31-
public bool AllThreadsContinued { get; set; }
31+
public bool AllThreadsContinued { get; init; }
3232
}
3333
}
3434
}

src/Dap.Protocol/Feature/Events/ExitedFeature.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ namespace Events
1616
GenerateHandlerMethods,
1717
GenerateRequestMethods
1818
]
19-
public class ExitedEvent : IRequest
19+
public record ExitedEvent : IRequest
2020
{
2121
/// <summary>
2222
/// The exit code returned from the debuggee.
2323
/// </summary>
24-
public long ExitCode { get; set; }
24+
public long ExitCode { get; init; }
2525
}
2626
}
2727
}

src/Dap.Protocol/Feature/Events/InitializedFeature.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace Events
1616
GenerateHandlerMethods,
1717
GenerateRequestMethods
1818
]
19-
public class InitializedEvent : IRequest
19+
public record InitializedEvent : IRequest
2020
{
2121
}
2222
}

src/Dap.Protocol/Feature/Events/LoadedSourceFeature.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,17 @@ namespace Events
1919
GenerateHandlerMethods,
2020
GenerateRequestMethods
2121
]
22-
public class LoadedSourceEvent : IRequest
22+
public record LoadedSourceEvent : IRequest
2323
{
2424
/// <summary>
2525
/// The reason for the event.
2626
/// </summary>
27-
public LoadedSourceReason Reason { get; set; }
27+
public LoadedSourceReason Reason { get; init; }
2828

2929
/// <summary>
3030
/// The new, changed, or removed source.
3131
/// </summary>
32-
public Source Source { get; set; } = null!;
32+
public Source Source { get; init; }
3333
}
3434

3535
[JsonConverter(typeof(StringEnumConverter))]

src/Dap.Protocol/Feature/Events/ModuleFeature.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,17 @@ namespace Events
1919
GenerateHandlerMethods,
2020
GenerateRequestMethods
2121
]
22-
public class ModuleEvent : IRequest
22+
public record ModuleEvent : IRequest
2323
{
2424
/// <summary>
2525
/// The reason for the event.
2626
/// </summary>
27-
public ModuleEventReason Reason { get; set; }
27+
public ModuleEventReason Reason { get; init; }
2828

2929
/// <summary>
3030
/// The new, changed, or removed module. In case of 'removed' only the module id is used.
3131
/// </summary>
32-
public Module Module { get; set; } = null!;
32+
public Module Module { get; init; }
3333
}
3434

3535
[JsonConverter(typeof(StringEnumConverter))]

src/Dap.Protocol/Feature/Events/OutputFeature.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,49 +19,49 @@ namespace Events
1919
GenerateHandlerMethods,
2020
GenerateRequestMethods
2121
]
22-
public class OutputEvent : IRequest
22+
public record OutputEvent : IRequest
2323
{
2424
/// <summary>
2525
/// The output category. If not specified, 'console' is assumed.
2626
/// Values: 'console', 'stdout', 'stderr', 'telemetry', etc.
2727
/// </summary>
2828
[Optional]
29-
public string? Category { get; set; }
29+
public string? Category { get; init; }
3030

3131
/// <summary>
3232
/// The output to report.
3333
/// </summary>
34-
public string Output { get; set; } = null!;
34+
public string Output { get; init; }
3535

3636
/// <summary>
3737
/// If an attribute 'variablesReference' exists and its value is > 0, the output contains objects which can be retrieved by passing 'variablesReference' to the 'variables' request.
3838
/// </summary>
3939
[Optional]
40-
public long? VariablesReference { get; set; }
40+
public long? VariablesReference { get; init; }
4141

4242
/// <summary>
4343
/// An optional source location where the output was produced.
4444
/// </summary>
4545
[Optional]
46-
public Source? Source { get; set; }
46+
public Source? Source { get; init; }
4747

4848
/// <summary>
4949
/// An optional source location line where the output was produced.
5050
/// </summary>
5151
[Optional]
52-
public long? Line { get; set; }
52+
public long? Line { get; init; }
5353

5454
/// <summary>
5555
/// An optional source location column where the output was produced.
5656
/// </summary>
5757
[Optional]
58-
public long? Column { get; set; }
58+
public long? Column { get; init; }
5959

6060
/// <summary>
6161
/// Optional data to report. For the 'telemetry' category the data will be sent to telemetry, for the other categories the data is shown in JSON format.
6262
/// </summary>
6363
[Optional]
64-
public JToken? Data { get; set; }
64+
public JToken? Data { get; init; }
6565
}
6666
}
6767
}

src/Dap.Protocol/Feature/Events/ProcessFeature.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,24 @@ namespace Events
1919
GenerateHandlerMethods,
2020
GenerateRequestMethods
2121
]
22-
public class ProcessEvent : IRequest
22+
public record ProcessEvent : IRequest
2323
{
2424
/// <summary>
2525
/// The logical name of the process. This is usually the full path to process's executable file. Example: /home/example/myproj/program.js.
2626
/// </summary>
27-
public string Name { get; set; } = null!;
27+
public string Name { get; init; }
2828

2929
/// <summary>
3030
/// The system process id of the debugged process. This property will be missing for non-system processes.
3131
/// </summary>
3232
[Optional]
33-
public long? SystemProcessId { get; set; }
33+
public long? SystemProcessId { get; init; }
3434

3535
/// <summary>
3636
/// If true, the process is running on the same computer as the debug adapter.
3737
/// </summary>
3838
[Optional]
39-
public bool IsLocalProcess { get; set; }
39+
public bool IsLocalProcess { get; init; }
4040

4141
/// <summary>
4242
/// Describes how the debug engine started debugging this process.
@@ -45,13 +45,13 @@ public class ProcessEvent : IRequest
4545
/// 'attachForSuspendedLaunch': A project launcher component has launched a new process in a suspended state and then asked the debugger to attach.
4646
/// </summary>
4747
[Optional]
48-
public ProcessEventStartMethod? StartMethod { get; set; }
48+
public ProcessEventStartMethod? StartMethod { get; init; }
4949

5050
/// <summary>
5151
/// The size of a pointer or address for this process, in bits. This value may be used by clients when formatting addresses for display.
5252
/// </summary>
5353
[Optional]
54-
public long? PointerSize { get; set; }
54+
public long? PointerSize { get; init; }
5555
}
5656

5757
[JsonConverter(typeof(StringEnumConverter))]

0 commit comments

Comments
 (0)