File tree Expand file tree Collapse file tree 3 files changed +30
-0
lines changed
src/Microsoft.OpenApi/Reader
test/Microsoft.OpenApi.Tests Expand file tree Collapse file tree 3 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -18,5 +18,13 @@ public class ReadResult
18
18
/// OpenApiDiagnostic contains the Errors reported while parsing
19
19
/// </summary>
20
20
public OpenApiDiagnostic Diagnostic { get ; set ; }
21
+ /// <summary>
22
+ /// Deconstructs the result for easier assignment on the client application.
23
+ /// </summary>
24
+ public void Deconstruct ( out OpenApiDocument document , out OpenApiDiagnostic diagnostic )
25
+ {
26
+ document = Document ;
27
+ diagnostic = Diagnostic ;
28
+ }
21
29
}
22
30
}
Original file line number Diff line number Diff line change @@ -1380,6 +1380,7 @@ namespace Microsoft.OpenApi.Reader
1380
1380
public ReadResult() { }
1381
1381
public Microsoft.OpenApi.Reader.OpenApiDiagnostic Diagnostic { get; set; }
1382
1382
public Microsoft.OpenApi.Models.OpenApiDocument Document { get; set; }
1383
+ public void Deconstruct(out Microsoft.OpenApi.Models.OpenApiDocument document, out Microsoft.OpenApi.Reader.OpenApiDiagnostic diagnostic) { }
1383
1384
}
1384
1385
public enum ReferenceResolutionSetting
1385
1386
{
Original file line number Diff line number Diff line change
1
+ using Xunit ;
2
+ using Microsoft . OpenApi . Reader ;
3
+ using Microsoft . OpenApi . Models ;
4
+
5
+ namespace Microsoft . OpenApi . Tests . Reader ;
6
+
7
+ public class ReadResultTests
8
+ {
9
+ [ Fact ]
10
+ public void Deconstructs ( )
11
+ {
12
+ var readResult = new ReadResult ( )
13
+ {
14
+ Document = new OpenApiDocument ( ) ,
15
+ Diagnostic = new OpenApiDiagnostic ( )
16
+ } ;
17
+ var ( document , diagnostic ) = readResult ;
18
+ Assert . Equal ( readResult . Document , document ) ;
19
+ Assert . Equal ( readResult . Diagnostic , diagnostic ) ;
20
+ }
21
+ }
You can’t perform that action at this time.
0 commit comments