Skip to content

Commit e05797c

Browse files
Add constraint to IDataPortal<T> and IChildDataPortal<T> to satisfy the constraint on the actual implementations.
1 parent 78a9402 commit e05797c

File tree

13 files changed

+31
-13
lines changed

13 files changed

+31
-13
lines changed

Source/Csla/DataPortalClient/DataPortalFactory.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using Microsoft.Extensions.DependencyInjection;
1010

1111
using System.Diagnostics.CodeAnalysis;
12+
using Csla.Core;
1213

1314
namespace Csla.DataPortalClient
1415
{
@@ -35,6 +36,7 @@ public DataPortalFactory(IServiceProvider serviceProvider)
3536
/// </summary>
3637
/// <typeparam name="T">Root business object type</typeparam>
3738
public IDataPortal<T> GetPortal<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] T>()
39+
where T : ICslaObject
3840
{
3941
return (IDataPortal<T>)_serviceProvider.GetRequiredService(typeof(IDataPortal<T>));
4042
}

Source/Csla/IChildDataPortalFactory.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
// <summary>Implements a data portal service</summary>
77
//-----------------------------------------------------------------------
88
using System.Diagnostics.CodeAnalysis;
9+
using Csla.Core;
910

1011
namespace Csla
1112
{
@@ -20,6 +21,7 @@ public interface IChildDataPortalFactory
2021
/// Get a child data portal instance.
2122
/// </summary>
2223
/// <typeparam name="T">Child business object type</typeparam>
23-
IChildDataPortal<T> GetPortal<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] T>();
24+
IChildDataPortal<T> GetPortal<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] T>()
25+
where T : ICslaObject;
2426
}
2527
}

Source/Csla/IChildDataPortalT.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
//-----------------------------------------------------------------------
88

99
using System.Diagnostics.CodeAnalysis;
10+
using Csla.Core;
1011

1112
namespace Csla
1213
{
@@ -15,6 +16,7 @@ namespace Csla
1516
/// </summary>
1617
/// <typeparam name="T"></typeparam>
1718
public interface IChildDataPortal<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] T>
19+
where T : ICslaObject
1820
{
1921
/// <summary>
2022
/// Starts an asynchronous data portal operation to

Source/Csla/IDataPortalFactory.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
// <summary>Implements a data portal service</summary>
77
//-----------------------------------------------------------------------
88
using System.Diagnostics.CodeAnalysis;
9+
using Csla.Core;
910

1011
namespace Csla
1112
{
@@ -20,6 +21,7 @@ public interface IDataPortalFactory
2021
/// Get a client-side data portal instance.
2122
/// </summary>
2223
/// <typeparam name="T">Root business object type</typeparam>
23-
IDataPortal<T> GetPortal<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] T>();
24+
IDataPortal<T> GetPortal<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] T>()
25+
where T : ICslaObject;
2426
}
2527
}

Source/Csla/IDataPortalT.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
//-----------------------------------------------------------------------
88

99
using System.Diagnostics.CodeAnalysis;
10+
using Csla.Core;
1011

1112
namespace Csla
1213
{
@@ -15,6 +16,7 @@ namespace Csla
1516
/// </summary>
1617
/// <typeparam name="T"></typeparam>
1718
public interface IDataPortal<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] T>
19+
where T : ICslaObject
1820
{
1921
/// <summary>
2022
/// Starts an asynchronous data portal operation to

Source/Csla/Server/ChildDataPortalFactory.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
//-----------------------------------------------------------------------
88

99
using System.Diagnostics.CodeAnalysis;
10-
10+
using Csla.Core;
1111
using Microsoft.Extensions.DependencyInjection;
1212

1313
namespace Csla.Server
@@ -35,6 +35,7 @@ public ChildDataPortalFactory(IServiceProvider serviceProvider)
3535
/// </summary>
3636
/// <typeparam name="T">Root business object type</typeparam>
3737
public IChildDataPortal<T> GetPortal<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)]T>()
38+
where T : ICslaObject
3839
{
3940
return _serviceProvider.GetRequiredService<IChildDataPortal<T>>();
4041
}

Source/tests/Csla.TestHelpers/DataPortalFactory.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
// <summary>Factory for dataportal instances for use in tests</summary>
77
//-----------------------------------------------------------------------
88

9+
using Csla.Core;
910
using Microsoft.Extensions.DependencyInjection;
1011

1112
namespace Csla.TestHelpers
@@ -19,7 +20,7 @@ public static class DataPortalFactory
1920
/// <typeparam name="T">The type which the data portal is to service</typeparam>
2021
/// <param name="context">The context from which configuration can be retrieved</param>
2122
/// <returns>An instance of IDataPortal<typeparamref name="T"/> for use in data access during tests</returns>
22-
public static IDataPortal<T> CreateDataPortal<T>(TestDIContext context)
23+
public static IDataPortal<T> CreateDataPortal<T>(TestDIContext context) where T : ICslaObject
2324
{
2425
IDataPortal<T> dataPortal;
2526

@@ -33,7 +34,7 @@ public static IDataPortal<T> CreateDataPortal<T>(TestDIContext context)
3334
/// <typeparam name="T">The type which the child data portal is to service</typeparam>
3435
/// <param name="context">The context from which configuration can be retrieved</param>
3536
/// <returns>An instance of IChildDataPortal<typeparamref name="T"/> for use in data access during tests</returns>
36-
public static IChildDataPortal<T> CreateChildDataPortal<T>(TestDIContext context)
37+
public static IChildDataPortal<T> CreateChildDataPortal<T>(TestDIContext context) where T : ICslaObject
3738
{
3839
IChildDataPortal<T> dataPortal;
3940

Source/tests/Csla.TestHelpers/TestDIContextExtensions.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
// <summary>Extension methods for the TestDIContext type</summary>
77
//-----------------------------------------------------------------------
88

9+
using Csla.Core;
10+
911
namespace Csla.TestHelpers
1012
{
1113

@@ -30,7 +32,7 @@ public static ApplicationContext CreateTestApplicationContext(this TestDIContext
3032
/// </summary>
3133
/// <param name="context">The context from which configuration can be retrieved</param>
3234
/// <returns>An instance of IDataPortal<typeparamref name="T"/> for use in testing</returns>
33-
public static IDataPortal<T> CreateDataPortal<T>(this TestDIContext context)
35+
public static IDataPortal<T> CreateDataPortal<T>(this TestDIContext context) where T : ICslaObject
3436
{
3537
return DataPortalFactory.CreateDataPortal<T>(context);
3638
}
@@ -40,7 +42,7 @@ public static IDataPortal<T> CreateDataPortal<T>(this TestDIContext context)
4042
/// </summary>
4143
/// <param name="context">The context from which configuration can be retrieved</param>
4244
/// <returns>An instance of IChildDataPortal<typeparamref name="T"/> for use in testing</returns>
43-
public static IChildDataPortal<T> CreateChildDataPortal<T>(this TestDIContext context)
45+
public static IChildDataPortal<T> CreateChildDataPortal<T>(this TestDIContext context) where T : ICslaObject
4446
{
4547
return DataPortalFactory.CreateChildDataPortal<T>(context);
4648
}

Source/tests/Csla.test/BusinessBase/BusynessTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
// <summary>no summary</summary>
77
//-----------------------------------------------------------------------
88
using Csla;
9+
using Csla.Core;
910
using Csla.TestHelpers;
1011
using Csla.Test;
1112
using Microsoft.VisualStudio.TestTools.UnitTesting;
@@ -97,7 +98,7 @@ public void IsBusyShouldNotGoInMinus()
9798
}
9899
}
99100

100-
private T CreateWithoutCriteria<T>()
101+
private T CreateWithoutCriteria<T>() where T : ICslaObject
101102
{
102103
IDataPortal<T> dataPortal = _testDIContext.CreateDataPortal<T>();
103104

Source/tests/Csla.test/PropertyGetSet/EditableGetSet.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
// <summary>no summary</summary>
77
//-----------------------------------------------------------------------
88

9+
using Csla.Core;
910
using Csla.Serialization.Mobile;
1011

1112
namespace Csla.Test.PropertyGetSet
@@ -294,7 +295,7 @@ protected override void OnSetState(SerializationInfo info, Core.StateMode mode)
294295
/// </summary>
295296
/// <typeparam name="T">The type which is to be accessed</typeparam>
296297
/// <returns>An instance of IDataPortal for use in data access</returns>
297-
private IDataPortal<T> GetDataPortal<T>() where T:class
298+
private IDataPortal<T> GetDataPortal<T>() where T : ICslaObject
298299
{
299300
return ApplicationContext.GetRequiredService<IDataPortal<T>>();
300301
}

0 commit comments

Comments
 (0)