-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make sure attributes used by compiler is not used in codegen + test f…
…or required modifier (#472)
- Loading branch information
1 parent
f786760
commit 415f3ec
Showing
2 changed files
with
38 additions
and
17 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
31 changes: 31 additions & 0 deletions
31
src/OpenRiaServices.Tools/Test/CodeGenRequiredModifierTests.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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#if NET7_0_OR_GREATER //required modifier does not work before net7 | ||
using System.ComponentModel.DataAnnotations; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using System; | ||
|
||
namespace OpenRiaServices.Tools.Test; | ||
|
||
/// <summary> | ||
/// CodeGen tests for the required modifier | ||
/// </summary> | ||
[TestClass] | ||
public class CodeGenRequiredModifierTests | ||
{ | ||
[TestMethod] | ||
[Description("CodeGen does not apply compiler exclusive attribute for required")] | ||
public void CodeGen_Required_Modifier_Dont_Use_Compiler_Attributes() | ||
{ | ||
MockSharedCodeService sts = TestHelper.CreateCommonMockSharedCodeService(); | ||
string generatedCode = TestHelper.GenerateCodeAssertSuccess("C#", new Type[] {typeof(Mock_CG_Required_Entity_DomainService) }, null, sts); | ||
TestHelper.AssertGeneratedCodeDoesNotContain(generatedCode, "RequiredMember"); | ||
} | ||
} | ||
|
||
public class Mock_CG_Required_Entity_DomainService : GenericDomainService<Mock_CG_Required_Entity> { } | ||
|
||
public class Mock_CG_Required_Entity | ||
{ | ||
[Key] | ||
public required string RequiredProperty { get; set; } | ||
} | ||
#endif |