Skip to content

Commit 1ffd775

Browse files
Adding NRT to WPF & MAUI (#4692)
* Add NRT to Wpf & MAUI * NRT WIP ticked * Changes to allow public interface changes to the main CSLA project that will not break the maui CI build is used in the shares xaml files. * Slight change to yaml for build. * Fix MacCatalysts minimum version for .net 8. * Fix project file * Changing the MacCatalyst version, and this time I mean it. --------- Co-authored-by: Kevin E. Ford <4380198+Bowman74@users.noreply.github.com>
1 parent 4b2c7e7 commit 1ffd775

29 files changed

+645
-448
lines changed

.github/workflows/ci.yaml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,5 @@ jobs:
7373
- name: "Select a specific version of Xcode"
7474
run: sudo xcode-select -s /Applications/Xcode_16.4.app
7575

76-
- name: Build iOS
77-
run: dotnet build Source/csla.maui.test.sln -f net9.0-ios
78-
79-
- name: Build Android
80-
run: dotnet build Source/csla.maui.test.sln -f net9.0-Android
81-
82-
- name: Build MacOS
83-
run: dotnet build Source/csla.maui.test.sln -f net9.0-maccatalyst
76+
- name: Build Solution
77+
run: dotnet build Source/csla.maui.test.sln --configuration Debug

Source/Csla.Xaml.Maui/Csla.Xaml.Maui.csproj

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<RootNamespace>Csla.Xaml</RootNamespace>
1616
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios' And $(TargetFramework) == 'net8.0-ios'">11.0</SupportedOSPlatformVersion>
1717
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios' And $(TargetFramework) != 'net8.0-ios'">12.2</SupportedOSPlatformVersion>
18-
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst' And $(TargetFramework) == 'net8.0-maccatalyst'">12.2</SupportedOSPlatformVersion>
18+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst' And $(TargetFramework) == 'net8.0-maccatalyst'">13.1</SupportedOSPlatformVersion>
1919
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst' And $(TargetFramework) != 'net8.0-maccatalyst'">15.0</SupportedOSPlatformVersion>
2020
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>
2121
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
@@ -33,15 +33,20 @@
3333
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="9.0.12" />
3434
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="9.0.0" />
3535
</ItemGroup>
36-
<ItemGroup>
36+
<ItemGroup Condition="'$(Configuration)'=='Release'">
3737
<PackageReference Include="Csla" Version="9.1.*" />
3838
</ItemGroup>
39-
39+
<ItemGroup Condition="'$(Configuration)'!='Release'">
40+
<ProjectReference Include="..\Csla\Csla.csproj" />
41+
</ItemGroup>
42+
4043
<PropertyGroup>
4144
<DefineConstants>$(DefineConstants);MAUI</DefineConstants>
4245
<Title>CSLA .NET for MAUI</Title>
4346
<PackageTags>CSLA;Business;MAUI</PackageTags>
4447
<PackageId>Csla.Maui</PackageId>
48+
<Nullable>enable</Nullable>
49+
<WarningsAsErrors>nullable</WarningsAsErrors>
4550
</PropertyGroup>
4651

4752
<Import Project="..\Csla.Xaml.Shared\Csla.Xaml.Shared.projitems" Label="Shared" />

Source/Csla.Xaml.Shared/ApplicationContextManager.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
// <summary>Provides consistent context information between the client</summary>
77
//-----------------------------------------------------------------------
88

9+
using System.Diagnostics.CodeAnalysis;
910
using System.Security.Principal;
1011
using Csla.Configuration;
1112

@@ -17,9 +18,9 @@ namespace Csla.Xaml
1718
/// <param name="securityOptions"></param>
1819
public class ApplicationContextManager(SecurityOptions securityOptions) : Csla.Core.ApplicationContextManager
1920
{
20-
private static IPrincipal _principal = null;
21-
private static ApplicationContext applicationContext;
22-
private SecurityOptions _securityOptions = securityOptions;
21+
private static IPrincipal? _principal = null;
22+
private static ApplicationContext? applicationContext;
23+
private readonly SecurityOptions _securityOptions = securityOptions;
2324

2425
/// <summary>
2526
/// Method called when the ApplicationContext
@@ -64,6 +65,7 @@ public override IPrincipal GetUser()
6465
}
6566

6667
/// <inheritdoc />
68+
[MemberNotNull(nameof(_principal))]
6769
public override void SetUser(IPrincipal principal)
6870
{
6971
_principal = principal ?? throw new ArgumentNullException(nameof(principal));

Source/Csla.Xaml.Shared/BrokenRulesSeverityConverter.cs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
// </copyright>
77
// <summary>Converts validation severity values into corresponding</summary>
88
//-----------------------------------------------------------------------
9-
using Csla.Rules;
10-
using System.Windows.Resources;
11-
using System.Windows.Media.Imaging;
129
using System.Windows;
1310
using System.Windows.Data;
11+
using System.Windows.Media.Imaging;
12+
using System.Windows.Resources;
13+
using Csla.Rules;
1414

1515
namespace Csla.Xaml
1616
{
@@ -28,16 +28,21 @@ public class BrokenRuleSeverityConverter : IValueConverter
2828
/// <param name="targetType">Desired output type (ignored).</param>
2929
/// <param name="parameter">Extra parameter (ignored).</param>
3030
/// <param name="culture">Desired culture (ignored).</param>
31-
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
31+
/// <exception cref="ArgumentException"><paramref name="value"/> is <see langword="null"/> or not of type <see cref="RuleSeverity"/>.</exception>
32+
public object? Convert(object? value, Type? targetType, object? parameter, System.Globalization.CultureInfo? culture)
3233
{
33-
RuleSeverity severity = (RuleSeverity)value;
34+
if (value is not RuleSeverity severity)
35+
{
36+
throw new ArgumentException($"{value?.GetType().ToString()} != typeof({nameof(RuleSeverity)})", nameof(value));
37+
}
38+
3439
string uri = $"/Csla.Xaml;component/Resources/{severity}.png";
3540
StreamResourceInfo sr = Application.GetResourceStream(new Uri(uri, UriKind.Relative));
3641
BitmapImage bmp = new BitmapImage();
3742
bmp.BeginInit();
3843
bmp.StreamSource = sr.Stream;
3944
bmp.EndInit();
40-
45+
4146
return bmp;
4247
}
4348

@@ -48,7 +53,7 @@ public object Convert(object value, Type targetType, object parameter, System.Gl
4853
/// <param name="targetType">Desired output type (ignored).</param>
4954
/// <param name="parameter">Extra parameter (ignored).</param>
5055
/// <param name="culture">Desired culture (ignored).</param>
51-
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
56+
public object? ConvertBack(object? value, Type? targetType, object? parameter, System.Globalization.CultureInfo? culture)
5257
{
5358
return RuleSeverity.Error;
5459
}

Source/Csla.Xaml.Shared/BusyAnimation.cs

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
// </copyright>
77
// <summary>Displays a busy animation.</summary>
88
//-----------------------------------------------------------------------
9+
using System.ComponentModel;
910
using System.Windows;
1011
using System.Windows.Controls;
1112
using System.Windows.Media;
1213
using System.Windows.Threading;
13-
using System.ComponentModel;
1414

1515
namespace Csla.Xaml
1616
{
@@ -36,15 +36,15 @@ namespace Csla.Xaml
3636
[TemplateVisualState(Name = "state8", GroupName = "CommonStates")]
3737
public class BusyAnimation : Control
3838
{
39-
#region Constants
39+
#region Constants
4040

4141
private const int NUM_STATES = 8;
4242

43-
#endregion
43+
#endregion
4444

45-
#region Member fields and properties
45+
#region Member fields and properties
4646

47-
private DispatcherTimer _timer;
47+
private DispatcherTimer? _timer;
4848
private int _state = -1;
4949

5050
/// <summary>
@@ -56,7 +56,7 @@ public class BusyAnimation : Control
5656
typeof(BusyAnimation),
5757
new PropertyMetadata(
5858
TimeSpan.FromMilliseconds(100),
59-
(o, e) =>
59+
(o, e) =>
6060
{
6161
var busyAnimation = (BusyAnimation)o;
6262
busyAnimation.StepInterval = (TimeSpan)e.NewValue;
@@ -106,9 +106,9 @@ private void SetupRunningState(bool isRunning)
106106
GoToState(true);
107107
}
108108

109-
#endregion
109+
#endregion
110110

111-
#region Constructor
111+
#region Constructor
112112

113113
/// <summary>
114114
/// Creates an instance of the control.
@@ -125,9 +125,9 @@ public BusyAnimation()
125125
LayoutUpdated += BusyAnimation_LayoutUpdated;
126126
}
127127

128-
#endregion
128+
#endregion
129129

130-
#region Timer
130+
#region Timer
131131

132132
private void StartTimer()
133133
{
@@ -150,7 +150,7 @@ private void StopTimer()
150150
}
151151
}
152152

153-
void timer_Tick(object sender, EventArgs e)
153+
void timer_Tick(object? sender, EventArgs e)
154154
{
155155
_state++;
156156
if (_state >= NUM_STATES)
@@ -159,9 +159,9 @@ void timer_Tick(object sender, EventArgs e)
159159
GoToState(true);
160160
}
161161

162-
#endregion
162+
#endregion
163163

164-
#region State
164+
#region State
165165

166166
private void GoToState(bool useTransitions)
167167
{
@@ -175,16 +175,16 @@ private void GoToState(bool useTransitions)
175175
}
176176
}
177177

178-
#endregion
178+
#endregion
179179

180-
#region Parts
180+
#region Parts
181181

182-
void BusyAnimation_LayoutUpdated(object sender, EventArgs e)
182+
void BusyAnimation_LayoutUpdated(object? sender, EventArgs e)
183183
{
184184
ArrangeParts();
185185
}
186186

187-
void BusyAnimation_SizeChanged(object sender, SizeChangedEventArgs e)
187+
void BusyAnimation_SizeChanged(object? sender, SizeChangedEventArgs e)
188188
{
189189
ArrangeParts();
190190
}
@@ -196,7 +196,7 @@ private void ArrangeParts()
196196

197197
for (int n = 0; n < NUM_STATES; n++)
198198
{
199-
FrameworkElement item = (FrameworkElement)FindChild(this, "part" + (n + 1));
199+
var item = (FrameworkElement?)FindChild(this, "part" + (n + 1));
200200
if (item != null)
201201
{
202202
double itemTheta = theta * n;
@@ -215,30 +215,31 @@ private void ArrangeParts()
215215
}
216216
}
217217

218-
#endregion
218+
#endregion
219219

220-
#region Helpers
220+
#region Helpers
221221

222-
private DependencyObject FindChild(DependencyObject parent, string name)
222+
private DependencyObject? FindChild(DependencyObject parent, string name)
223223
{
224-
DependencyObject found = null;
224+
DependencyObject? found = null;
225225
int count = VisualTreeHelper.GetChildrenCount(parent);
226226
for (int x = 0; x < count; x++)
227227
{
228228
DependencyObject child = VisualTreeHelper.GetChild(parent, x);
229-
string childName = child.GetValue(NameProperty) as string;
229+
string? childName = child.GetValue(NameProperty) as string;
230230
if (childName == name)
231231
{
232232
found = child;
233233
break;
234234
}
235-
else found = FindChild(child, name);
235+
else
236+
found = FindChild(child, name);
236237
}
237238

238239
return found;
239240
}
240241

241-
#endregion
242+
#endregion
242243
}
243244
}
244245
#endif

Source/Csla.Xaml.Shared/ConfigurationExtensions.cs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public static class XamlConfigurationExtensions
2121
/// environments.
2222
/// </summary>
2323
/// <param name="config">CslaConfiguration object</param>
24+
/// <exception cref="ArgumentNullException"><paramref name="config"/> is <see langword="null"/>.</exception>
2425
public static CslaOptions AddXaml(this CslaOptions config)
2526
{
2627
return AddXaml(config, null);
@@ -32,8 +33,12 @@ public static CslaOptions AddXaml(this CslaOptions config)
3233
/// </summary>
3334
/// <param name="config">CslaConfiguration object</param>
3435
/// <param name="options">XamlOptions action</param>
35-
public static CslaOptions AddXaml(this CslaOptions config, Action<XamlOptions> options)
36+
/// <exception cref="ArgumentNullException"><paramref name="config"/> is <see langword="null"/>.</exception>
37+
public static CslaOptions AddXaml(this CslaOptions config, Action<XamlOptions>? options)
3638
{
39+
if (config is null)
40+
throw new ArgumentNullException(nameof(config));
41+
3742
var xamlOptions = new XamlOptions();
3843
options?.Invoke(xamlOptions);
3944

@@ -55,8 +60,12 @@ public static CslaOptions AddXaml(this CslaOptions config, Action<XamlOptions> o
5560
/// Initializes CSLA for use by Xaml apps.
5661
/// </summary>
5762
/// <param name="host"></param>
63+
/// <exception cref="ArgumentNullException"><paramref name="host"/> is <see langword="null"/>.</exception>
5864
public static IHost UseCsla(this IHost host)
5965
{
66+
if (host is null)
67+
throw new ArgumentNullException(nameof(host));
68+
6069
// create instance of ApplicationContext so the
6170
// Csla.Xaml.ApplicationContextManager gets a static
6271
// reference for use by UI helpers.
@@ -67,8 +76,3 @@ public static IHost UseCsla(this IHost host)
6776
}
6877
#endif
6978
}
70-
71-
/// <summary>
72-
/// Configuration options for AddXaml method
73-
/// </summary>
74-
public class XamlOptions;

Source/Csla.Xaml.Shared/Csla.Xaml.Shared.projitems

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,6 @@
3030
<Compile Include="$(MSBuildThisFileDirectory)TriggerAction.cs" />
3131
<Compile Include="$(MSBuildThisFileDirectory)ViewModel.cs" />
3232
<Compile Include="$(MSBuildThisFileDirectory)ViewModelBase.cs" />
33+
<Compile Include="$(MSBuildThisFileDirectory)XamlOptions.cs" />
3334
</ItemGroup>
3435
</Project>

0 commit comments

Comments
 (0)