diff --git a/src/Libraries/NRefactory/Project/Src/PrettyPrinter/VBNet/VBNetOutputVisitor.cs b/src/Libraries/NRefactory/Project/Src/PrettyPrinter/VBNet/VBNetOutputVisitor.cs index 1760cebb6d..90cae73eb5 100644 --- a/src/Libraries/NRefactory/Project/Src/PrettyPrinter/VBNet/VBNetOutputVisitor.cs +++ b/src/Libraries/NRefactory/Project/Src/PrettyPrinter/VBNet/VBNetOutputVisitor.cs @@ -459,18 +459,18 @@ namespace ICSharpCode.NRefactory.PrettyPrinter switch (optionDeclaration.OptionType) { case OptionType.Strict: outputFormatter.PrintToken(Tokens.Strict); - if (!optionDeclaration.OptionValue) { - outputFormatter.Space(); - outputFormatter.PrintToken(Tokens.Off); - } + outputFormatter.Space(); + outputFormatter.PrintToken(optionDeclaration.OptionValue ? Tokens.On : Tokens.Off); break; case OptionType.Explicit: outputFormatter.PrintToken(Tokens.Explicit); outputFormatter.Space(); - if (!optionDeclaration.OptionValue) { - outputFormatter.Space(); - outputFormatter.PrintToken(Tokens.Off); - } + outputFormatter.PrintToken(optionDeclaration.OptionValue ? Tokens.On : Tokens.Off); + break; + case OptionType.Infer: + outputFormatter.PrintToken(Tokens.Infer); + outputFormatter.Space(); + outputFormatter.PrintToken(optionDeclaration.OptionValue ? Tokens.On : Tokens.Off); break; case OptionType.CompareBinary: outputFormatter.PrintToken(Tokens.Compare); @@ -658,11 +658,13 @@ namespace ICSharpCode.NRefactory.PrettyPrinter this.AppendCommaSeparatedList(eventDeclaration.Parameters); outputFormatter.PrintToken(Tokens.CloseParenthesis); } - outputFormatter.Space(); - outputFormatter.PrintToken(Tokens.As); - outputFormatter.Space(); - VisitReturnTypeAttributes(eventDeclaration.Attributes, data); - TrackedVisit(eventDeclaration.TypeReference, data); + if (!eventDeclaration.TypeReference.IsNull) { + outputFormatter.Space(); + outputFormatter.PrintToken(Tokens.As); + outputFormatter.Space(); + VisitReturnTypeAttributes(eventDeclaration.Attributes, data); + TrackedVisit(eventDeclaration.TypeReference, data); + } PrintInterfaceImplementations(eventDeclaration.InterfaceImplementations); diff --git a/src/Libraries/NRefactory/Test/Output/VBNet/VBNetOutputTest.cs b/src/Libraries/NRefactory/Test/Output/VBNet/VBNetOutputTest.cs index 97cb95fb57..54d1dc2d52 100644 --- a/src/Libraries/NRefactory/Test/Output/VBNet/VBNetOutputTest.cs +++ b/src/Libraries/NRefactory/Test/Output/VBNet/VBNetOutputTest.cs @@ -482,5 +482,20 @@ End Using"); " .Encoding = Encoding.UTF8 _\n" + "}"); } + + [Test] + public void EventDefinition() + { + TestTypeMember("Public Event MyEvent(ByVal sender As Object)"); + } + + [Test] + public void Options() + { + TestProgram("Option Strict On\n" + + "Option Explicit On\n" + + "Option Infer On\n" + + "Option Compare Text"); + } } }