Skip to content

Commit

Permalink
Don't force inherited messages to be abstract
Browse files Browse the repository at this point in the history
  • Loading branch information
ltrzesniewski committed Oct 29, 2020
1 parent aedb146 commit 4585b31
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
12 changes: 12 additions & 0 deletions src/Abc.Zebus.MessageDsl.Tests/MessageDsl/CSharpGeneratorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,18 @@ public void should_generate_internal_enums()
code.ShouldContain("internal enum Foo");
}

[Test]
public void should_generate_unsealed_messages()
{
var code = Generate(new MessageDefinition
{
Name = "FooExecuted",
InheritanceModifier = InheritanceModifier.None
});

code.ShouldContain("public partial class FooExecuted : IEvent");
}

[Test]
public void should_generate_sealed_messages()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -337,10 +337,10 @@ public void should_default_to_sealed_message_classes()
}

[Test]
public void should_make_inherited_messages_abstract()
public void should_not_mark_inherited_messages_as_sealed()
{
var contracts = ParseValid("[ProtoInclude(10, typeof(MsgB))] MsgA(); MsgB() : MsgA;");
contracts.Messages[0].InheritanceModifier.ShouldEqual(InheritanceModifier.Abstract);
contracts.Messages[0].InheritanceModifier.ShouldEqual(InheritanceModifier.None);
}

[Test]
Expand Down
2 changes: 1 addition & 1 deletion src/Abc.Zebus.MessageDsl/Analysis/AstProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ private static void SetInheritanceModifier(MessageDefinition message)
var hasInheritedMessages = message.Attributes.Any(attr => Equals(attr.TypeName, KnownTypes.ProtoIncludeAttribute));

message.InheritanceModifier = hasInheritedMessages
? InheritanceModifier.Abstract
? InheritanceModifier.None
: InheritanceModifier.Sealed;
}
}
Expand Down

0 comments on commit 4585b31

Please sign in to comment.