Skip to content

Commit

Permalink
Fix issue with ReactiveUI 19.5.31 System.Text.Json (#612)
Browse files Browse the repository at this point in the history
Xamarin does not support System.Text.Json due to the inclusion of System.Buffers, Xamarin falls back to Netstandard2.0 within the package causing the System.Buffers lib to load
  • Loading branch information
ChrisPulman authored Jan 9, 2024
1 parent 540fafe commit 2f315e2
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 30 deletions.
4 changes: 2 additions & 2 deletions src/Directory.build.props
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Nerdbank.GitVersioning" Version="3.6.133" PrivateAssets="all" />
<PackageReference Include="stylecop.analyzers" Version="1.2.0-beta.507" PrivateAssets="all" />
<PackageReference Include="Roslynator.Analyzers" Version="4.6.2" PrivateAssets="All" />
<PackageReference Include="stylecop.analyzers" Version="1.2.0-beta.556" PrivateAssets="all" />
<PackageReference Include="Roslynator.Analyzers" Version="4.7.0" PrivateAssets="All" />
</ItemGroup>
<ItemGroup>
<AdditionalFiles Include="$(MSBuildThisFileDirectory)stylecop.json" Link="stylecop.json" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="xunit" Version="2.6.2" />
<PackageReference Include="xunit" Version="2.6.4" />
<PackageReference Include="xunit.runner.console" Version="2.6.4" />
<PackageReference Include="Xunit.StaFact" Version="1.1.11" />
<PackageReference Include="Microsoft.Reactive.Testing" Version="6.0.0" />
<PackageReference Include="PublicApiGenerator" Version="11.0.0" />
<PackageReference Include="Verify.Xunit" Version="22.8.0" />
<PackageReference Include="xunit.runner.console" Version="2.6.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.4" />
<PackageReference Include="PublicApiGenerator" Version="11.1.0" />
<PackageReference Include="Verify.Xunit" Version="22.11.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.6" />
<PackageReference Include="coverlet.msbuild" Version="6.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="DiffEngine" Version="13.0.2" />
<PackageReference Include="DiffEngine" Version="15.0.1" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ internal Enumerator(ReadOnlyCollectionPooled<T> readOnlyCollectionPooled)
_current = default;
}

public T Current => _current!;
public readonly T Current => _current!;

object? IEnumerator.Current
readonly object? IEnumerator.Current
{
get
{
Expand Down
2 changes: 1 addition & 1 deletion src/ReactiveUI.Validation/Collections/ValidationText.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public static class ValidationText
/// <summary>
/// The none validation text singleton instance contains no items.
/// </summary>
public static readonly IValidationText None = new ArrayValidationText(Array.Empty<string>());
public static readonly IValidationText None = new ArrayValidationText([]);

/// <summary>
/// The empty validation text singleton instance contains single empty string.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ public abstract class BasePropertyValidation<TViewModel> : ReactiveObject, IDisp
{
[SuppressMessage("Usage", "CA2213:Disposable fields should be disposed", Justification = "Disposed by field _disposables.")]
private readonly ReplaySubject<bool> _isValidSubject = new(1);
private readonly HashSet<string> _propertyNames = new();
private readonly CompositeDisposable _disposables = new();
private readonly HashSet<string> _propertyNames = [];
private readonly CompositeDisposable _disposables = [];
private IConnectableObservable<IValidationState>? _connectedChange;
private bool _isConnected;
private bool _isValid;
Expand Down Expand Up @@ -171,7 +171,7 @@ public sealed class BasePropertyValidation<TViewModel, TViewModelProperty> : Bas
private readonly IConnectableObservable<TViewModelProperty?> _valueConnectedObservable;
private readonly Func<TViewModelProperty?, bool, IValidationText> _message;
private readonly Func<TViewModelProperty?, bool> _isValidFunc;
private readonly CompositeDisposable _disposables = new();
private readonly CompositeDisposable _disposables = [];
private bool _isConnected;

/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions src/ReactiveUI.Validation/Components/ObservableValidation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,8 @@ public abstract class ObservableValidationBase<TViewModel, TValue> : ReactiveObj
{
[SuppressMessage("Usage", "CA2213:Disposable fields should be disposed", Justification = "Disposed by field _disposables.")]
private readonly ReplaySubject<IValidationState> _isValidSubject = new(1);
private readonly HashSet<string> _propertyNames = new();
private readonly CompositeDisposable _disposables = new();
private readonly HashSet<string> _propertyNames = [];
private readonly CompositeDisposable _disposables = [];
private readonly IConnectableObservable<IValidationState> _validityConnectedObservable;
private bool _isActive;
private bool _isValid;
Expand Down
2 changes: 1 addition & 1 deletion src/ReactiveUI.Validation/Contexts/ValidationContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class ValidationContext : ReactiveObject, IDisposable, IValidationCompone
private readonly ObservableAsPropertyHelper<IValidationText> _validationText;
private readonly ObservableAsPropertyHelper<bool> _isValid;

private readonly CompositeDisposable _disposables = new();
private readonly CompositeDisposable _disposables = [];
private bool _isActive;

/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions src/ReactiveUI.Validation/Helpers/ReactiveValidationObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace ReactiveUI.Validation.Helpers;
/// </summary>
public abstract class ReactiveValidationObject : ReactiveObject, IValidatableViewModel, INotifyDataErrorInfo
{
private readonly HashSet<string> _mentionedPropertyNames = new();
private readonly HashSet<string> _mentionedPropertyNames = [];
private readonly IValidationTextFormatter<string> _formatter;
private bool _hasErrors;

Expand Down Expand Up @@ -140,4 +140,4 @@ private void OnValidationStatusChange(IValidationComponent component)
}
}
}
}
}
16 changes: 7 additions & 9 deletions src/ReactiveUI.Validation/ReactiveUI.Validation.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="MSBuild.Sdk.Extras">
<Project Sdk="MSBuild.Sdk.Extras">

<PropertyGroup>
<TargetFrameworks>MonoAndroid13.0;Xamarin.iOS10;Xamarin.Mac20;Xamarin.TVOS10;tizen40;netstandard2.0;net6.0;net7.0;net7.0-android;net7.0-ios;net7.0-tvos;net7.0-macos;net7.0-maccatalyst;net8.0;net8.0-android;net8.0-ios;net8.0-tvos;net8.0-macos;net8.0-maccatalyst</TargetFrameworks>
Expand All @@ -7,14 +7,12 @@
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="ReactiveUI" Version="19.*" />
<ItemGroup Condition="!$(TargetFramework.StartsWith('Xamarin'))">
<PackageReference Include="ReactiveUI" Version="19.5.31" />
</ItemGroup>

<ItemGroup Condition="$(TargetFramework.StartsWith('netstandard'))">
<PackageReference Include="System.Buffers" Version="4.5.1" />
</ItemGroup>
<ItemGroup Condition="$(TargetFramework.StartsWith('net4'))">
<PackageReference Include="System.Buffers" Version="4.5.1" />

<!--Xamarin does not support System.Text.Json due to the inclusion of System.Buffers, the latest version (19.5.31) of ReactiveUI includes System.Text.Json-->
<ItemGroup Condition="$(TargetFramework.StartsWith('Xamarin'))">
<PackageReference Include="ReactiveUI" Version="19.5.1" />
</ItemGroup>
</Project>
3 changes: 1 addition & 2 deletions src/global.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"sdk": {
"version": "8.0.10",
"rollForward": "latestMinor",
"allowPrerelease": true
"rollForward": "latestMinor"
},
"msbuild-sdks": {
"MSBuild.Sdk.Extras": "3.0.44"
Expand Down

0 comments on commit 2f315e2

Please sign in to comment.