-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #9 - Disallow default(Foo) by emitting a build error
- Loading branch information
Showing
6 changed files
with
225 additions
and
108 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,30 @@ | ||
using System; | ||
using Vogen; | ||
#pragma warning disable CS0219 | ||
|
||
namespace Vogen.Examples.NoDefaulting | ||
{ | ||
/* | ||
You shouldn't be allowed to `default` a Value Object as it bypasses | ||
any validation you might have added. | ||
*/ | ||
|
||
public class Naughty | ||
{ | ||
public Naughty() | ||
{ | ||
// uncomment for - error VOG009: Type 'CustomerId' cannot be constructed with default as it is prohibited. | ||
// CustomerId c = default; | ||
// var c2 = default(CustomerId); | ||
|
||
// VendorId v = default; | ||
// var v2 = default(VendorId); | ||
} | ||
} | ||
|
||
[ValueObject(typeof(int))] | ||
public partial struct CustomerId { } | ||
|
||
[ValueObject(typeof(int))] | ||
public partial class VendorId { } | ||
} |
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
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
Oops, something went wrong.