-
-
Notifications
You must be signed in to change notification settings - Fork 406
Allow disabling scan for data annotations attributes #4614
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 8 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
b889c39
#4492 Allow disabling scan for data annotations attributes
rockfordlhotka 0ca2c3a
Fix test broken due to rule caching
rockfordlhotka 0f26fbb
Fix comments
rockfordlhotka aa301d3
#4615 Ensure ApplicationContext isn't null during initialization
rockfordlhotka 0285c4c
Fix broken test
rockfordlhotka 92adaea
Add missing test config
rockfordlhotka 4ec9279
#4492 Make Options property internal
rockfordlhotka f2442e2
Merge branch 'v9.x' into dev/4492-rules-9
StefanOssendorf fa35d10
Merge branch 'v9.x' into dev/4492-rules-9
rockfordlhotka 551ffc5
#4492 Revert breaking change
rockfordlhotka 47c8467
#4492 Fix comment
rockfordlhotka 40c3f17
#4492 Don't cache options object
rockfordlhotka 03d9e81
Suppress warnings about async
rockfordlhotka badc0d6
#4492 Skip test on CI server
rockfordlhotka File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<RunSettings> | ||
<RunConfiguration> | ||
<MaxCpuCount>1</MaxCpuCount> | ||
</RunConfiguration> | ||
</RunSettings> |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,90 @@ | ||
//----------------------------------------------------------------------- | ||
// <copyright file="BusinessRuleTests.cs" company="Marimer LLC"> | ||
// Copyright (c) Marimer LLC. All rights reserved. | ||
// Website: https://cslanet.com | ||
// </copyright> | ||
// <summary>no summary</summary> | ||
//----------------------------------------------------------------------- | ||
using System.ComponentModel.DataAnnotations; | ||
using Csla.Configuration; | ||
using Csla.TestHelpers; | ||
using FluentAssertions; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
namespace Csla.Test.BizRules | ||
{ | ||
[TestClass] | ||
public class BusinessRuleTests | ||
{ | ||
private static TestDIContext _testDIContext; | ||
|
||
[ClassInitialize] | ||
public static void ClassInitialize(TestContext context) | ||
{ | ||
_testDIContext = TestDIContextFactory.CreateDefaultContext(); | ||
} | ||
|
||
[TestInitialize] | ||
public void Initialize() | ||
{ | ||
TestResults.Reinitialise(); | ||
} | ||
|
||
[TestMethod] | ||
public void DefaultDataAnnotationsScan() | ||
{ | ||
var portal = _testDIContext.ServiceProvider.GetRequiredService<IDataPortal<TestBusinessRule>>(); | ||
var obj = portal.Create(); | ||
obj.Name = ""; | ||
obj.IsValid.Should().BeFalse(); | ||
} | ||
|
||
[TestMethod] | ||
public void DisableDataAnnotationsScan() | ||
{ | ||
var options = _testDIContext.ServiceProvider.GetRequiredService<CslaOptions>(); | ||
options.ScanForDataAnnotations(false); | ||
|
||
// use different type to avoid caching | ||
var portal = _testDIContext.ServiceProvider.GetRequiredService<IDataPortal<TestBusinessRule2>>(); | ||
var obj = portal.Create(); | ||
obj.Name = ""; | ||
obj.IsValid.Should().BeTrue(); | ||
} | ||
} | ||
|
||
public class TestBusinessRule : BusinessBase<TestBusinessRule> | ||
{ | ||
public static readonly PropertyInfo<string> NameProperty = RegisterProperty<string>(nameof(Name)); | ||
[Required] | ||
public string Name | ||
{ | ||
get => GetProperty(NameProperty); | ||
set => SetProperty(NameProperty, value); | ||
} | ||
|
||
[Create] | ||
private void Create() | ||
{ | ||
BusinessRules.CheckRules(); | ||
} | ||
} | ||
|
||
public class TestBusinessRule2 : BusinessBase<TestBusinessRule2> | ||
{ | ||
public static readonly PropertyInfo<string> NameProperty = RegisterProperty<string>(nameof(Name)); | ||
[Required] | ||
public string Name | ||
{ | ||
get => GetProperty(NameProperty); | ||
set => SetProperty(NameProperty, value); | ||
} | ||
|
||
[Create] | ||
private void Create() | ||
{ | ||
BusinessRules.CheckRules(); | ||
} | ||
} | ||
} |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
@@ -1,15 +1,15 @@ | ||
//----------------------------------------------------------------------- | ||
// <copyright file="HttpProxyOptions.cs" company="Marimer LLC"> | ||
// <copyright file="CoreOptions.cs" company="Marimer LLC"> | ||
// Copyright (c) Marimer LLC. All rights reserved. | ||
// Website: https://cslanet.com | ||
// </copyright> | ||
// <summary>Options for data binding</summary> | ||
// <summary>Internal class used to configure CSLA .NET</summary> | ||
//----------------------------------------------------------------------- | ||
|
||
namespace Csla.Configuration | ||
{ | ||
/// <summary> | ||
/// Options for data binding | ||
/// Internal class used to configure CSLA .NET | ||
/// </summary> | ||
public class CoreOptions; | ||
} |
This file contains hidden or 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 hidden or 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 hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.