Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
333fred committed Jan 7, 2025
1 parent c555c1b commit 5eed5e2
Showing 1 changed file with 25 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -638,23 +638,24 @@ End Class
Dim parseOptions = TestOptions.Regular
Dim compilation As Compilation = CreateCompilation(source, parseOptions:=parseOptions)
compilation.VerifyDiagnostics()

Assert.Single(compilation.SyntaxTrees)

Dim generator = New IncrementalGeneratorWrapper(New PipelineCallbackGenerator(Sub(ctx)
ctx.RegisterPostInitializationOutput(Sub(c) c.AddEmbeddedAttributeDefinition())
End Sub))


Dim generator = New IncrementalGeneratorWrapper(New PipelineCallbackGenerator(
Sub(ctx)
ctx.RegisterPostInitializationOutput(Sub(c) c.AddEmbeddedAttributeDefinition())
End Sub))

Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=TestOptions.GeneratorDriverOptions)
Dim outputCompilation As Compilation = Nothing
Dim diagnostics As ImmutableArray(Of Diagnostic) = Nothing
driver = driver.RunGeneratorsAndUpdateCompilation(compilation, outputCompilation, diagnostics)
Dim runResult = driver.GetRunResult().Results(0)

Assert.Single(runResult.GeneratedSources)

Dim generatedSource = runResult.GeneratedSources(0)

Assert.Equal("Namespace Microsoft.CodeAnalysis
Friend NotInheritable Partial Class EmbeddedAttribute
Inherits Global.System.Attribute
Expand All @@ -664,7 +665,7 @@ End Namespace", generatedSource.SourceText.ToString())

outputCompilation.VerifyDiagnostics()
End Sub

<Fact>
Public Sub IncrementalGenerator_PostInit_AddEmbeddedAttributeSource_DoubleAdd_Throws()
Dim source = "
Expand All @@ -674,24 +675,26 @@ End Class
Dim parseOptions = TestOptions.Regular
Dim compilation As Compilation = CreateCompilation(source, parseOptions:=parseOptions)
compilation.VerifyDiagnostics()

Assert.Single(compilation.SyntaxTrees)

Dim generator = New IncrementalGeneratorWrapper(New PipelineCallbackGenerator(Sub(ctx)
ctx.RegisterPostInitializationOutput(Sub(c)
c.AddEmbeddedAttributeDefinition()
Assert.Throws(Of ArgumentException)("hintName", Sub() c.AddEmbeddedAttributeDefinition())
End Sub)
End Sub))


Dim generator = New IncrementalGeneratorWrapper(New PipelineCallbackGenerator(
Sub(ctx)
ctx.RegisterPostInitializationOutput(
Sub(c)
c.AddEmbeddedAttributeDefinition()
Assert.Throws(Of ArgumentException)("hintName", Sub() c.AddEmbeddedAttributeDefinition())
End Sub)
End Sub))

Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=TestOptions.GeneratorDriverOptions)
driver = driver.RunGenerators(compilation)
Dim runResult = driver.GetRunResult().Results(0)

Assert.Single(runResult.GeneratedSources)

Dim generatedSource = runResult.GeneratedSources(0)

Assert.Equal("Namespace Microsoft.CodeAnalysis
Friend NotInheritable Partial Class EmbeddedAttribute
Inherits Global.System.Attribute
Expand Down

0 comments on commit 5eed5e2

Please sign in to comment.