Skip to content

Commit

Permalink
feature: .net 5 and C# 9, tvos (#294)
Browse files Browse the repository at this point in the history
  • Loading branch information
glennawatson committed Dec 15, 2020
1 parent 2800518 commit d843512
Show file tree
Hide file tree
Showing 96 changed files with 791 additions and 1,674 deletions.
66 changes: 48 additions & 18 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,13 @@ csharp_new_line_between_query_expression_clauses = true
csharp_indent_block_contents = true
csharp_indent_braces = false
csharp_indent_case_contents = true
csharp_indent_case_contents_when_block = true
csharp_indent_switch_labels = true
csharp_indent_labels = one_less_than_current

# Modifier preferences
csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:suggestion

# avoid this. unless absolutely necessary
dotnet_style_qualification_for_field = false:suggestion
dotnet_style_qualification_for_property = false:suggestion
Expand All @@ -40,59 +44,80 @@ dotnet_style_qualification_for_event = false:suggestion

# only use var when it's obvious what the variable type is
csharp_style_var_for_built_in_types = false:none
csharp_style_var_when_type_is_apparent = false:suggestion
csharp_style_var_elsewhere = false:suggestion
csharp_style_var_when_type_is_apparent = true:suggestion
csharp_style_var_elsewhere = true:suggestion

# use language keywords instead of BCL types
# Types: use keywords instead of BCL types, and permit var only when the type is clear
csharp_style_var_for_built_in_types = false:suggestion
csharp_style_var_when_type_is_apparent = false:none
csharp_style_var_elsewhere = false:suggestion
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
dotnet_style_predefined_type_for_member_access = true:suggestion

# name all constant fields using PascalCase
dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols = constant_fields
dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style

dotnet_naming_symbols.constant_fields.applicable_kinds = field
dotnet_naming_symbols.constant_fields.required_modifiers = const

dotnet_naming_style.pascal_case_style.capitalization = pascal_case

# static fields should have s_ prefix
dotnet_naming_rule.static_fields_should_have_prefix.severity = suggestion
dotnet_naming_rule.static_fields_should_have_prefix.symbols = static_fields
dotnet_naming_rule.static_fields_should_have_prefix.style = static_prefix_style
dotnet_naming_symbols.static_fields.applicable_kinds = field
dotnet_naming_symbols.static_fields.required_modifiers = static

dotnet_naming_style.static_prefix_style.capitalization = camel_case
dotnet_naming_symbols.static_fields.applicable_accessibilities = private, internal, private_protected
dotnet_naming_style.static_prefix_style.required_prefix = s_
dotnet_naming_style.static_prefix_style.capitalization = camel_case

# internal and private fields should be _camelCase
dotnet_naming_rule.camel_case_for_private_internal_fields.severity = suggestion
dotnet_naming_rule.camel_case_for_private_internal_fields.symbols = private_internal_fields
dotnet_naming_rule.camel_case_for_private_internal_fields.style = camel_case_underscore_style

dotnet_naming_symbols.private_internal_fields.applicable_kinds = field
dotnet_naming_symbols.private_internal_fields.applicable_accessibilities = private, internal

dotnet_naming_style.camel_case_underscore_style.required_prefix = _
dotnet_naming_style.camel_case_underscore_style.capitalization = camel_case
dotnet_naming_style.camel_case_underscore_style.capitalization = camel_case

# Code style defaults
csharp_using_directive_placement = outside_namespace:suggestion
dotnet_sort_system_directives_first = true
csharp_preserve_single_line_blocks = true
csharp_preserve_single_line_statements = false
csharp_prefer_braces = true:silent
csharp_preserve_single_line_blocks = true:none
csharp_preserve_single_line_statements = false:none
csharp_prefer_static_local_function = true:suggestion
csharp_prefer_simple_using_statement = false:none
csharp_style_prefer_switch_expression = true:suggestion

# Code quality
dotnet_style_readonly_field = true:suggestion
dotnet_code_quality_unused_parameters = non_public:suggestion

# Expression-level preferences
dotnet_style_object_initializer = true:suggestion
dotnet_style_collection_initializer = true:suggestion
dotnet_style_explicit_tuple_names = true:suggestion
dotnet_style_coalesce_expression = true:suggestion
dotnet_style_null_propagation = true:suggestion
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
dotnet_style_prefer_inferred_tuple_names = true:suggestion
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
dotnet_style_prefer_auto_properties = true:suggestion
dotnet_style_prefer_conditional_expression_over_assignment = true:silent
dotnet_style_prefer_conditional_expression_over_return = true:silent
csharp_prefer_simple_default_expression = true:suggestion

# Expression-bodied members
csharp_style_expression_bodied_methods = false:none
csharp_style_expression_bodied_constructors = false:none
csharp_style_expression_bodied_operators = false:none
csharp_style_expression_bodied_methods = true:suggestion
csharp_style_expression_bodied_constructors = true:suggestion
csharp_style_expression_bodied_operators = true:suggestion
csharp_style_expression_bodied_properties = true:suggestion
csharp_style_expression_bodied_indexers = true:none
csharp_style_expression_bodied_accessors = true:none
csharp_style_expression_bodied_indexers = true:suggestion
csharp_style_expression_bodied_accessors = true:suggestion
csharp_style_expression_bodied_lambdas = true:suggestion
csharp_style_expression_bodied_local_functions = true:suggestion

# Pattern matching
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
Expand All @@ -103,6 +128,11 @@ csharp_style_inlined_variable_declaration = true:suggestion
csharp_style_throw_expression = true:suggestion
csharp_style_conditional_delegate_call = true:suggestion

# Other features
csharp_style_prefer_index_operator = false:none
csharp_style_prefer_range_operator = false:none
csharp_style_pattern_local_over_anonymous_function = false:none

# Space preferences
csharp_space_after_cast = false
csharp_space_after_colon_in_inheritance_clause = true
Expand Down Expand Up @@ -152,4 +182,4 @@ indent_size = 2
[*.sh]
end_of_line = lf
[*.{cmd, bat}]
end_of_line = crlf
end_of_line = crlf
7 changes: 2 additions & 5 deletions Sample/SextantSample.Android/MainActivity.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
using System;
using Android;

using Android.App;
using Android.Content.PM;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;

namespace SextantSample.Droid
Expand All @@ -19,7 +16,7 @@ protected override void OnCreate(Bundle bundle)

base.OnCreate(bundle);

global::Xamarin.Forms.Forms.Init(this, bundle);
Xamarin.Forms.Forms.Init(this, bundle);
LoadApplication(new App());
}
}
Expand Down
4 changes: 2 additions & 2 deletions Sample/SextantSample.Android/Properties/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.giusepe.SextantSample" android:installLocation="auto">
<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="28" />
<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="29" />
<application android:label="SextantSample.Android"></application>
</manifest>
</manifest>
5 changes: 3 additions & 2 deletions Sample/SextantSample.Android/SextantSample.Android.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest>
<MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix>
<MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix>
<TargetFrameworkVersion>v9.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v10.0</TargetFrameworkVersion>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
Expand Down Expand Up @@ -74,6 +74,7 @@
<PackageReference Include="Xamarin.Android.Support.v7.CardView" Version="28.0.0.3" />
<PackageReference Include="Xamarin.Android.Support.v7.MediaRouter" Version="28.0.0.3" />
<PackageReference Include="ReactiveUI.XamForms" Version="13.*" />
<PackageReference Include="Xamarin.AndroidX.MediaRouter" Version="1.1.0.1" />
</ItemGroup>
<ItemGroup>
<Compile Include="MainActivity.cs" />
Expand Down Expand Up @@ -121,4 +122,4 @@
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
</Project>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<PackageReference Include="Avalonia.ReactiveUI" Version="0.10.0-preview6" />
<PackageReference Include="Citrus.Avalonia" Version="1.3.0-preview" />
<PackageReference Include="MessageBox.Avalonia" Version="0.10.0-prev2" />
<PackageReference Include="ReactiveUI" Version="13.*" />
</ItemGroup>
<ItemGroup>
<Compile Update="**\*.xaml.cs">
Expand Down
1 change: 0 additions & 1 deletion Sample/SextantSample.Core/FirstModalNavigationViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using ReactiveUI;
using Sextant;

namespace SextantSample.ViewModels
Expand Down
6 changes: 1 addition & 5 deletions Sample/SextantSample.Core/FirstModalViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using Sextant;
using System;
using System.Diagnostics;
using Splat;

namespace SextantSample.ViewModels
{
Expand Down Expand Up @@ -33,9 +32,6 @@ public FirstModalViewModel(IViewStackService viewStackService) : base(viewStackS
}


public void Destroy()
{
Debug.WriteLine($"Destroy: {nameof(FirstModalViewModel)}");
}
public void Destroy() => Debug.WriteLine($"Destroy: {nameof(FirstModalViewModel)}");
}
}
10 changes: 2 additions & 8 deletions Sample/SextantSample.Core/GreenViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.Diagnostics;
using System.Reactive;
using System.Reactive.Disposables;
using System.Reactive.Linq;
using ReactiveUI;
using Sextant;
Expand All @@ -11,13 +10,11 @@ namespace SextantSample.ViewModels
public class GreenViewModel : ViewModelBase, INavigable, IDestructible
{
public GreenViewModel(IViewStackService viewStackService)
: base(viewStackService)
{
: base(viewStackService) =>
OpenModal = ReactiveCommand
.CreateFromObservable(() =>
ViewStackService.PushModal(new FirstModalViewModel(viewStackService), string.Empty, false),
outputScheduler: RxApp.MainThreadScheduler);
}

public override string Id { get; } = string.Empty;

Expand All @@ -32,9 +29,6 @@ public IObservable<Unit> WhenNavigatedFrom(INavigationParameter parameter) =>
public IObservable<Unit> WhenNavigatingTo(INavigationParameter parameter) =>
Observable.Return(Unit.Default);

public void Destroy()
{
Debug.WriteLine($"Destroy: {nameof(GreenViewModel)}");
}
public void Destroy() => Debug.WriteLine($"Destroy: {nameof(GreenViewModel)}");
}
}
2 changes: 0 additions & 2 deletions Sample/SextantSample.Core/HomeViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using System;
using System.Diagnostics;
using System.Reactive;
using System.Reactive.Linq;
using ReactiveUI;
using Sextant;
using Splat;
Expand Down
4 changes: 1 addition & 3 deletions Sample/SextantSample.Core/Interactions.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
using System;
using System.Collections.Generic;
using System.Text;
using ReactiveUI;

namespace SextantSample.ViewModels
{
public static class Interactions
{
public static Interaction<Exception, bool> ErrorMessage = new Interaction<Exception, bool>();
public static readonly Interaction<Exception, bool> ErrorMessage = new Interaction<Exception, bool>();
}
}
4 changes: 1 addition & 3 deletions Sample/SextantSample.Core/RedViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
using System;
using System.Diagnostics;
using System.Reactive;
using System.Reactive.Linq;
using System.Windows.Input;
using ReactiveUI;
using Sextant;

namespace SextantSample.ViewModels
{
public class RedViewModel : ViewModelBase, IViewModel
public class RedViewModel : ViewModelBase
{
public ReactiveCommand<Unit, Unit> PopModal { get; set; }

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using ReactiveUI;
using Sextant;

namespace SextantSample.ViewModels
{
Expand Down
3 changes: 1 addition & 2 deletions Sample/SextantSample.Core/SecondModalViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using System;
using System.Diagnostics;
using Sextant;
using System.Reactive.Linq;

namespace SextantSample.ViewModels
{
Expand All @@ -28,7 +27,7 @@ public SecondModalViewModel(IViewStackService viewStackService) : base(viewStack
outputScheduler: RxApp.MainThreadScheduler);

PushPage.Subscribe(x => Debug.WriteLine("PagePushed"));
PopModal.Subscribe(x => Debug.WriteLine("PagePoped"));
PopModal.Subscribe(x => Debug.WriteLine("PagePopped"));

PushPage.ThrownExceptions.Subscribe(error => Interactions.ErrorMessage.Handle(error).Subscribe());
PopModal.ThrownExceptions.Subscribe(error => Interactions.ErrorMessage.Handle(error).Subscribe());
Expand Down
10 changes: 7 additions & 3 deletions Sample/SextantSample.Core/SextantDefaultExceptionHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public void OnNext(Exception ex)
Debugger.Break();
}

RxApp.MainThreadScheduler.Schedule(() => { throw ex; });
RxApp.MainThreadScheduler.Schedule(() => throw ex);
}

public void OnError(Exception ex)
Expand All @@ -23,14 +23,18 @@ public void OnError(Exception ex)
{
Debugger.Break();
}
RxApp.MainThreadScheduler.Schedule(() => { throw ex; });

RxApp.MainThreadScheduler.Schedule(() => throw ex);
}

public void OnCompleted()
{
if (Debugger.IsAttached)
{
Debugger.Break();
RxApp.MainThreadScheduler.Schedule(() => { throw new NotImplementedException(); });
}

RxApp.MainThreadScheduler.Schedule(() => throw new NotImplementedException());
}
}
}
2 changes: 1 addition & 1 deletion Sample/SextantSample.Core/SextantSample.ViewModels.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="ReactiveUI" Version="12.*" />
<PackageReference Include="ReactiveUI" Version="13.*" />
</ItemGroup>

<ItemGroup>
Expand Down
6 changes: 1 addition & 5 deletions Sample/SextantSample.Core/ViewModelBase.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Reactive;
using ReactiveUI;
using Sextant;

Expand All @@ -9,10 +8,7 @@ public abstract class ViewModelBase : ReactiveObject, IViewModel
{
protected readonly IViewStackService ViewStackService;

protected ViewModelBase(IViewStackService viewStackService)
{
ViewStackService = viewStackService;
}
protected ViewModelBase(IViewStackService viewStackService) => ViewStackService = viewStackService;

public virtual string Id { get; }
}
Expand Down
Loading

0 comments on commit d843512

Please sign in to comment.