Skip to content

Commit

Permalink
Update to latest C# 9 syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
glennawatson committed Dec 13, 2020
1 parent 2504abd commit 5abaa90
Show file tree
Hide file tree
Showing 31 changed files with 184 additions and 251 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ namespace ReactiveUI.Validation.Collections
public string this[int index] { get; }
public System.Collections.Generic.IEnumerator<string> GetEnumerator() { }
public string ToSingleLine(string? separator = ",") { }
public static ReactiveUI.Validation.Collections.ValidationText Create(System.Collections.Generic.IEnumerable<ReactiveUI.Validation.Collections.ValidationText> validationTexts) { }
public static ReactiveUI.Validation.Collections.ValidationText Create(System.Collections.Generic.IEnumerable<string> validationTexts) { }
public static ReactiveUI.Validation.Collections.ValidationText Create(params string[] validationTexts) { }
public static ReactiveUI.Validation.Collections.ValidationText Create(System.Collections.Generic.IEnumerable<ReactiveUI.Validation.Collections.ValidationText>? validationTexts) { }
public static ReactiveUI.Validation.Collections.ValidationText Create(System.Collections.Generic.IEnumerable<string>? validationTexts) { }
public static ReactiveUI.Validation.Collections.ValidationText Create(params string?[]? validationTexts) { }
}
}
namespace ReactiveUI.Validation.Comparators
{
public class ValidationStateComparer : System.Collections.Generic.EqualityComparer<ReactiveUI.Validation.States.IValidationState>
{
public ValidationStateComparer() { }
public override bool Equals(ReactiveUI.Validation.States.IValidationState x, ReactiveUI.Validation.States.IValidationState y) { }
public override bool Equals(ReactiveUI.Validation.States.IValidationState? x, ReactiveUI.Validation.States.IValidationState? y) { }
public override int GetHashCode(ReactiveUI.Validation.States.IValidationState obj) { }
}
}
Expand Down Expand Up @@ -189,7 +189,7 @@ namespace ReactiveUI.Validation.Formatters
{
public SingleLineFormatter(string? separator = null) { }
public static ReactiveUI.Validation.Formatters.SingleLineFormatter Default { get; }
public string Format(ReactiveUI.Validation.Collections.ValidationText validationText) { }
public string Format(ReactiveUI.Validation.Collections.ValidationText? validationText) { }
}
}
namespace ReactiveUI.Validation.Helpers
Expand All @@ -200,14 +200,14 @@ namespace ReactiveUI.Validation.Helpers
public bool HasErrors { get; }
public ReactiveUI.Validation.Contexts.ValidationContext ValidationContext { get; }
public event System.EventHandler<System.ComponentModel.DataErrorsChangedEventArgs>? ErrorsChanged;
public virtual System.Collections.IEnumerable GetErrors(string propertyName) { }
public virtual System.Collections.IEnumerable GetErrors(string? propertyName) { }
protected void RaiseErrorsChanged(string propertyName = "") { }
}
public class ValidationHelper : ReactiveUI.ReactiveObject, System.IDisposable
{
public ValidationHelper(ReactiveUI.Validation.Components.Abstractions.IValidationComponent validation, System.IDisposable? cleanup = null) { }
public bool IsValid { get; }
public ReactiveUI.Validation.Collections.ValidationText? Message { get; }
public ReactiveUI.Validation.Collections.ValidationText Message { get; }
public System.IObservable<ReactiveUI.Validation.States.IValidationState> ValidationChanged { get; }
public void Dispose() { }
protected virtual void Dispose(bool disposing) { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ namespace ReactiveUI.Validation.Collections
public string this[int index] { get; }
public System.Collections.Generic.IEnumerator<string> GetEnumerator() { }
public string ToSingleLine(string? separator = ",") { }
public static ReactiveUI.Validation.Collections.ValidationText Create(System.Collections.Generic.IEnumerable<ReactiveUI.Validation.Collections.ValidationText> validationTexts) { }
public static ReactiveUI.Validation.Collections.ValidationText Create(System.Collections.Generic.IEnumerable<string> validationTexts) { }
public static ReactiveUI.Validation.Collections.ValidationText Create(params string[] validationTexts) { }
public static ReactiveUI.Validation.Collections.ValidationText Create(System.Collections.Generic.IEnumerable<ReactiveUI.Validation.Collections.ValidationText>? validationTexts) { }
public static ReactiveUI.Validation.Collections.ValidationText Create(System.Collections.Generic.IEnumerable<string>? validationTexts) { }
public static ReactiveUI.Validation.Collections.ValidationText Create(params string?[]? validationTexts) { }
}
}
namespace ReactiveUI.Validation.Comparators
{
public class ValidationStateComparer : System.Collections.Generic.EqualityComparer<ReactiveUI.Validation.States.IValidationState>
{
public ValidationStateComparer() { }
public override bool Equals(ReactiveUI.Validation.States.IValidationState x, ReactiveUI.Validation.States.IValidationState y) { }
public override bool Equals(ReactiveUI.Validation.States.IValidationState? x, ReactiveUI.Validation.States.IValidationState? y) { }
public override int GetHashCode(ReactiveUI.Validation.States.IValidationState obj) { }
}
}
Expand Down Expand Up @@ -189,7 +189,7 @@ namespace ReactiveUI.Validation.Formatters
{
public SingleLineFormatter(string? separator = null) { }
public static ReactiveUI.Validation.Formatters.SingleLineFormatter Default { get; }
public string Format(ReactiveUI.Validation.Collections.ValidationText validationText) { }
public string Format(ReactiveUI.Validation.Collections.ValidationText? validationText) { }
}
}
namespace ReactiveUI.Validation.Helpers
Expand All @@ -200,14 +200,14 @@ namespace ReactiveUI.Validation.Helpers
public bool HasErrors { get; }
public ReactiveUI.Validation.Contexts.ValidationContext ValidationContext { get; }
public event System.EventHandler<System.ComponentModel.DataErrorsChangedEventArgs>? ErrorsChanged;
public virtual System.Collections.IEnumerable GetErrors(string propertyName) { }
public virtual System.Collections.IEnumerable GetErrors(string? propertyName) { }
protected void RaiseErrorsChanged(string propertyName = "") { }
}
public class ValidationHelper : ReactiveUI.ReactiveObject, System.IDisposable
{
public ValidationHelper(ReactiveUI.Validation.Components.Abstractions.IValidationComponent validation, System.IDisposable? cleanup = null) { }
public bool IsValid { get; }
public ReactiveUI.Validation.Collections.ValidationText? Message { get; }
public ReactiveUI.Validation.Collections.ValidationText Message { get; }
public System.IObservable<ReactiveUI.Validation.States.IValidationState> ValidationChanged { get; }
public void Dispose() { }
protected virtual void Dispose(bool disposing) { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ namespace ReactiveUI.Validation.Collections
public string this[int index] { get; }
public System.Collections.Generic.IEnumerator<string> GetEnumerator() { }
public string ToSingleLine(string? separator = ",") { }
public static ReactiveUI.Validation.Collections.ValidationText Create(System.Collections.Generic.IEnumerable<ReactiveUI.Validation.Collections.ValidationText> validationTexts) { }
public static ReactiveUI.Validation.Collections.ValidationText Create(System.Collections.Generic.IEnumerable<string> validationTexts) { }
public static ReactiveUI.Validation.Collections.ValidationText Create(params string[] validationTexts) { }
public static ReactiveUI.Validation.Collections.ValidationText Create(System.Collections.Generic.IEnumerable<ReactiveUI.Validation.Collections.ValidationText>? validationTexts) { }
public static ReactiveUI.Validation.Collections.ValidationText Create(System.Collections.Generic.IEnumerable<string>? validationTexts) { }
public static ReactiveUI.Validation.Collections.ValidationText Create(params string?[]? validationTexts) { }
}
}
namespace ReactiveUI.Validation.Comparators
{
public class ValidationStateComparer : System.Collections.Generic.EqualityComparer<ReactiveUI.Validation.States.IValidationState>
{
public ValidationStateComparer() { }
public override bool Equals(ReactiveUI.Validation.States.IValidationState x, ReactiveUI.Validation.States.IValidationState y) { }
public override bool Equals(ReactiveUI.Validation.States.IValidationState? x, ReactiveUI.Validation.States.IValidationState? y) { }
public override int GetHashCode(ReactiveUI.Validation.States.IValidationState obj) { }
}
}
Expand Down Expand Up @@ -189,7 +189,7 @@ namespace ReactiveUI.Validation.Formatters
{
public SingleLineFormatter(string? separator = null) { }
public static ReactiveUI.Validation.Formatters.SingleLineFormatter Default { get; }
public string Format(ReactiveUI.Validation.Collections.ValidationText validationText) { }
public string Format(ReactiveUI.Validation.Collections.ValidationText? validationText) { }
}
}
namespace ReactiveUI.Validation.Helpers
Expand All @@ -200,14 +200,14 @@ namespace ReactiveUI.Validation.Helpers
public bool HasErrors { get; }
public ReactiveUI.Validation.Contexts.ValidationContext ValidationContext { get; }
public event System.EventHandler<System.ComponentModel.DataErrorsChangedEventArgs>? ErrorsChanged;
public virtual System.Collections.IEnumerable GetErrors(string propertyName) { }
public virtual System.Collections.IEnumerable GetErrors(string? propertyName) { }
protected void RaiseErrorsChanged(string propertyName = "") { }
}
public class ValidationHelper : ReactiveUI.ReactiveObject, System.IDisposable
{
public ValidationHelper(ReactiveUI.Validation.Components.Abstractions.IValidationComponent validation, System.IDisposable? cleanup = null) { }
public bool IsValid { get; }
public ReactiveUI.Validation.Collections.ValidationText? Message { get; }
public ReactiveUI.Validation.Collections.ValidationText Message { get; }
public System.IObservable<ReactiveUI.Validation.States.IValidationState> ValidationChanged { get; }
public void Dispose() { }
protected virtual void Dispose(bool disposing) { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ namespace ReactiveUI.Validation.Collections
public string this[int index] { get; }
public System.Collections.Generic.IEnumerator<string> GetEnumerator() { }
public string ToSingleLine(string? separator = ",") { }
public static ReactiveUI.Validation.Collections.ValidationText Create(System.Collections.Generic.IEnumerable<ReactiveUI.Validation.Collections.ValidationText> validationTexts) { }
public static ReactiveUI.Validation.Collections.ValidationText Create(System.Collections.Generic.IEnumerable<string> validationTexts) { }
public static ReactiveUI.Validation.Collections.ValidationText Create(params string[] validationTexts) { }
public static ReactiveUI.Validation.Collections.ValidationText Create(System.Collections.Generic.IEnumerable<ReactiveUI.Validation.Collections.ValidationText>? validationTexts) { }
public static ReactiveUI.Validation.Collections.ValidationText Create(System.Collections.Generic.IEnumerable<string>? validationTexts) { }
public static ReactiveUI.Validation.Collections.ValidationText Create(params string?[]? validationTexts) { }
}
}
namespace ReactiveUI.Validation.Comparators
{
public class ValidationStateComparer : System.Collections.Generic.EqualityComparer<ReactiveUI.Validation.States.IValidationState>
{
public ValidationStateComparer() { }
public override bool Equals(ReactiveUI.Validation.States.IValidationState x, ReactiveUI.Validation.States.IValidationState y) { }
public override bool Equals(ReactiveUI.Validation.States.IValidationState? x, ReactiveUI.Validation.States.IValidationState? y) { }
public override int GetHashCode(ReactiveUI.Validation.States.IValidationState obj) { }
}
}
Expand Down Expand Up @@ -189,7 +189,7 @@ namespace ReactiveUI.Validation.Formatters
{
public SingleLineFormatter(string? separator = null) { }
public static ReactiveUI.Validation.Formatters.SingleLineFormatter Default { get; }
public string Format(ReactiveUI.Validation.Collections.ValidationText validationText) { }
public string Format(ReactiveUI.Validation.Collections.ValidationText? validationText) { }
}
}
namespace ReactiveUI.Validation.Helpers
Expand All @@ -200,14 +200,14 @@ namespace ReactiveUI.Validation.Helpers
public bool HasErrors { get; }
public ReactiveUI.Validation.Contexts.ValidationContext ValidationContext { get; }
public event System.EventHandler<System.ComponentModel.DataErrorsChangedEventArgs>? ErrorsChanged;
public virtual System.Collections.IEnumerable GetErrors(string propertyName) { }
public virtual System.Collections.IEnumerable GetErrors(string? propertyName) { }
protected void RaiseErrorsChanged(string propertyName = "") { }
}
public class ValidationHelper : ReactiveUI.ReactiveObject, System.IDisposable
{
public ValidationHelper(ReactiveUI.Validation.Components.Abstractions.IValidationComponent validation, System.IDisposable? cleanup = null) { }
public bool IsValid { get; }
public ReactiveUI.Validation.Collections.ValidationText? Message { get; }
public ReactiveUI.Validation.Collections.ValidationText Message { get; }
public System.IObservable<ReactiveUI.Validation.States.IValidationState> ValidationChanged { get; }
public void Dispose() { }
protected virtual void Dispose(bool disposing) { }
Expand Down
12 changes: 5 additions & 7 deletions src/ReactiveUI.Validation.Tests/API/ApiApprovalTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,13 @@ namespace ReactiveUI.Validation.Tests.API
[ExcludeFromCodeCoverage]
public class ApiApprovalTests
{
private static readonly Regex _removeCoverletSectionRegex = new Regex(@"^namespace Coverlet\.Core\.Instrumentation\.Tracker.*?^}", RegexOptions.Singleline | RegexOptions.Multiline | RegexOptions.Compiled);
private static readonly Regex _removeCoverletSectionRegex = new(@"^namespace Coverlet\.Core\.Instrumentation\.Tracker.*?^}", RegexOptions.Singleline | RegexOptions.Multiline | RegexOptions.Compiled);

/// <summary>
/// Tests to make sure the splat project is approved.
/// </summary>
[Fact]
public void ValidationProject()
{
CheckApproval(typeof(ValidationBinding).Assembly);
}
public void ValidationProject() => CheckApproval(typeof(ValidationBinding).Assembly);

private static void CheckApproval(Assembly assembly, [CallerMemberName]string memberName = null, [CallerFilePath]string filePath = null)
{
Expand All @@ -57,7 +54,7 @@ private static void CheckApproval(Assembly assembly, [CallerMemberName]string me
var approvedPublicApi = File.ReadAllText(approvedFileName);

var generatorOptions = new ApiGeneratorOptions { WhitelistedNamespacePrefixes = new[] { "ReactiveUI.Validation" } };
var receivedPublicApi = Filter(ApiGenerator.GeneratePublicApi(assembly, generatorOptions));
var receivedPublicApi = Filter(assembly.GeneratePublicApi(generatorOptions));

if (!string.Equals(receivedPublicApi, approvedPublicApi, StringComparison.InvariantCulture))
{
Expand All @@ -75,7 +72,8 @@ private static string Filter(string text)
new[]
{
Environment.NewLine
}, StringSplitOptions.RemoveEmptyEntries)
},
StringSplitOptions.RemoveEmptyEntries)
.Where(l =>
!l.StartsWith("[assembly: AssemblyVersion(", StringComparison.InvariantCulture) &&
!l.StartsWith("[assembly: AssemblyFileVersion(", StringComparison.InvariantCulture) &&
Expand Down
5 changes: 1 addition & 4 deletions src/ReactiveUI.Validation.Tests/Models/IndeiTestView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ public class IndeiTestView : IViewFor<IndeiTestViewModel>
/// Initializes a new instance of the <see cref="IndeiTestView"/> class.
/// </summary>
/// <param name="viewModel">ViewModel instance of type <see cref="TestViewModel"/>.</param>
public IndeiTestView(IndeiTestViewModel viewModel)
{
ViewModel = viewModel;
}
public IndeiTestView(IndeiTestViewModel viewModel) => ViewModel = viewModel;

/// <inheritdoc/>
object IViewFor.ViewModel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ public class SourceDestinationView : IViewFor<SourceDestinationViewModel>
/// Initializes a new instance of the <see cref="SourceDestinationView"/> class.
/// </summary>
/// <param name="viewModel">ViewModel instance of type <see cref="SourceDestinationViewModel"/>.</param>
public SourceDestinationView(SourceDestinationViewModel viewModel)
{
ViewModel = viewModel;
}
public SourceDestinationView(SourceDestinationViewModel viewModel) => ViewModel = viewModel;

/// <inheritdoc/>
object IViewFor.ViewModel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ namespace ReactiveUI.Validation.Tests.Models
/// </summary>
public class SourceDestinationViewModel : ReactiveObject, IValidatableViewModel
{
private TestViewModel _source = new TestViewModel();
private TestViewModel _destination = new TestViewModel();
private TestViewModel _source = new();
private TestViewModel _destination = new();

/// <summary>
/// Gets or sets get the Name.
Expand All @@ -36,6 +36,6 @@ public TestViewModel Destination
}

/// <inheritdoc/>
public ValidationContext ValidationContext { get; } = new ValidationContext(Scheduler.Immediate);
public ValidationContext ValidationContext { get; } = new(Scheduler.Immediate);
}
}
7 changes: 2 additions & 5 deletions src/ReactiveUI.Validation.Tests/Models/TestView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@ public TestView()
/// Initializes a new instance of the <see cref="TestView"/> class.
/// </summary>
/// <param name="viewModel">ViewModel instance of type <see cref="TestViewModel"/>.</param>
public TestView(TestViewModel viewModel)
{
ViewModel = viewModel;
}
public TestView(TestViewModel viewModel) => ViewModel = viewModel;

/// <inheritdoc/>
object IViewFor.ViewModel
Expand Down Expand Up @@ -70,6 +67,6 @@ public TestViewModel ViewModel
/// <summary>
/// Gets the error label which is represented by a container.
/// </summary>
public TestControl NameErrorContainer { get; } = new TestControl();
public TestControl NameErrorContainer { get; } = new();
}
}
2 changes: 1 addition & 1 deletion src/ReactiveUI.Validation.Tests/Models/TestViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@ public ValidationHelper NameRule
}

/// <inheritdoc/>
public ValidationContext ValidationContext { get; } = new ValidationContext(ImmediateScheduler.Instance);
public ValidationContext ValidationContext { get; } = new(ImmediateScheduler.Instance);
}
}
Loading

0 comments on commit 5abaa90

Please sign in to comment.