-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: diagnostic converter when location is empty (#290)
- Loading branch information
1 parent
3c75435
commit aac665d
Showing
12 changed files
with
145 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
using Microsoft.CodeAnalysis; | ||
|
||
[Generator] | ||
public class HelloWorldVbGeneratorWithoutLocation : | ||
HelloWorldVbGenerator | ||
{ | ||
protected override Location? GetLocation() => null; | ||
} |
8 changes: 8 additions & 0 deletions
8
src/Tests/SampleVbTest.DriverWithoutLocation#helloWorld.verified.vb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
//HintName: helloWorld.vb | ||
Imports System | ||
|
||
Public Module HelloWorld | ||
Public Sub SayHello() | ||
Console.WriteLine("Hello from generated code!") | ||
End Sub | ||
End Module |
6 changes: 6 additions & 0 deletions
6
src/Tests/SampleVbTest.DriverWithoutLocation#helper.verified.vb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
//HintName: helper.vb | ||
Imports System | ||
Public Module Helper | ||
Public Sub Method() | ||
End Sub | ||
End Module |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
Diagnostics: [ | ||
{ | ||
Id: theId, | ||
Title: the title, | ||
Severity: Info, | ||
WarningLevel: 1, | ||
MessageFormat: the message from {0}, | ||
Message: the message from hello world generator, | ||
Category: the category | ||
} | ||
] | ||
} |
36 changes: 36 additions & 0 deletions
36
src/Tests/SampleVbTest.RunResultWithoutLocation.verified.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
Generator: {}, | ||
GeneratedSources: [ | ||
{ | ||
HintName: helper.vb, | ||
Source: | ||
Imports System | ||
Public Module Helper | ||
Public Sub Method() | ||
End Sub | ||
End Module | ||
}, | ||
{ | ||
HintName: helloWorld.vb, | ||
Source: | ||
Imports System | ||
|
||
Public Module HelloWorld | ||
Public Sub SayHello() | ||
Console.WriteLine("Hello from generated code!") | ||
End Sub | ||
End Module | ||
} | ||
], | ||
Diagnostics: [ | ||
{ | ||
Id: theId, | ||
Title: the title, | ||
Severity: Info, | ||
WarningLevel: 1, | ||
MessageFormat: the message from {0}, | ||
Message: the message from hello world generator, | ||
Category: the category | ||
} | ||
] | ||
} |
8 changes: 8 additions & 0 deletions
8
src/Tests/SampleVbTest.RunResultsWithoutLocation#helloWorld.verified.vb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
//HintName: helloWorld.vb | ||
Imports System | ||
|
||
Public Module HelloWorld | ||
Public Sub SayHello() | ||
Console.WriteLine("Hello from generated code!") | ||
End Sub | ||
End Module |
6 changes: 6 additions & 0 deletions
6
src/Tests/SampleVbTest.RunResultsWithoutLocation#helper.verified.vb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
//HintName: helper.vb | ||
Imports System | ||
Public Module Helper | ||
Public Sub Method() | ||
End Sub | ||
End Module |
13 changes: 13 additions & 0 deletions
13
src/Tests/SampleVbTest.RunResultsWithoutLocation.verified.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
Diagnostics: [ | ||
{ | ||
Id: theId, | ||
Title: the title, | ||
Severity: Info, | ||
WarningLevel: 1, | ||
MessageFormat: the message from {0}, | ||
Message: the message from hello world generator, | ||
Category: the category | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 2 additions & 7 deletions
9
src/Verify.SourceGenerators/Converters/FileLinePositionSpanConverter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,6 @@ | ||
class FileLinePositionSpanConverter : | ||
WriteOnlyJsonConverter<FileLinePositionSpan> | ||
{ | ||
public override void Write(VerifyJsonWriter writer, FileLinePositionSpan value) | ||
{ | ||
if (value.IsValid) | ||
{ | ||
writer.WriteValue($"{value.Path.Replace('/', '\\')}: {value.Span}"); | ||
} | ||
} | ||
public override void Write(VerifyJsonWriter writer, FileLinePositionSpan value) => | ||
writer.WriteValue(value.IsValid ? $"{value.Path.Replace('/', '\\')}: {value.Span}" : ""); | ||
} |