Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: Add .net 6 support, help from @chrispulman #756

Merged
merged 4 commits into from
Aug 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 24 additions & 20 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@ root = true
insert_final_newline = true
indent_style = space
indent_size = 4

[project.json]
indent_size = 2
trim_trailing_whitespace = true

# C# files
[*.cs]

# New line preferences
csharp_new_line_before_open_brace = all
csharp_new_line_before_else = true
Expand All @@ -42,15 +41,10 @@ dotnet_style_qualification_for_property = false:suggestion
dotnet_style_qualification_for_method = false:suggestion
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 = true:suggestion
csharp_style_var_elsewhere = true:suggestion

# 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 =true:none
csharp_style_var_elsewhere =true:suggestion
csharp_style_var_for_built_in_types = true:suggestion
csharp_style_var_when_type_is_apparent = true:none
csharp_style_var_elsewhere = true:suggestion
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
dotnet_style_predefined_type_for_member_access = true:suggestion

Expand All @@ -62,14 +56,14 @@ 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
# static fields should have _ 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_symbols.static_fields.applicable_accessibilities = private, internal, private_protected
dotnet_naming_style.static_prefix_style.required_prefix = s_
dotnet_naming_style.static_prefix_style.required_prefix = _
dotnet_naming_style.static_prefix_style.capitalization = camel_case

# internal and private fields should be _camelCase
Expand All @@ -84,7 +78,7 @@ 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_prefer_braces = true:silent
csharp_prefer_braces = true:suggestion
csharp_preserve_single_line_blocks = true:none
csharp_preserve_single_line_statements = false:none
csharp_prefer_static_local_function = true:suggestion
Expand All @@ -105,8 +99,8 @@ dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggesti
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
dotnet_style_prefer_conditional_expression_over_assignment = true:suggestion
dotnet_style_prefer_conditional_expression_over_return = true:suggestion
csharp_prefer_simple_default_expression = true:suggestion

# Expression-bodied members
Expand Down Expand Up @@ -163,7 +157,6 @@ dotnet_diagnostic.AvoidAsyncVoid.severity = suggestion
dotnet_diagnostic.CA1000.severity = none
dotnet_diagnostic.CA1001.severity = error
dotnet_diagnostic.CA1009.severity = error
dotnet_diagnostic.CA1014.severity = none
dotnet_diagnostic.CA1016.severity = error
dotnet_diagnostic.CA1030.severity = none
dotnet_diagnostic.CA1031.severity = none
Expand All @@ -187,7 +180,6 @@ dotnet_diagnostic.CA1410.severity = error
dotnet_diagnostic.CA1415.severity = error
dotnet_diagnostic.CA1507.severity = error
dotnet_diagnostic.CA1710.severity = suggestion
dotnet_diagnostic.CA1716.severity = suggestion
dotnet_diagnostic.CA1724.severity = none
dotnet_diagnostic.CA1810.severity = none
dotnet_diagnostic.CA1821.severity = error
Expand Down Expand Up @@ -250,6 +242,7 @@ dotnet_diagnostic.RCS1074.severity = error
dotnet_diagnostic.RCS1090.severity = error
dotnet_diagnostic.RCS1138.severity = error
dotnet_diagnostic.RCS1139.severity = error
dotnet_diagnostic.RCS1158.severity = none
dotnet_diagnostic.RCS1163.severity = suggestion
dotnet_diagnostic.RCS1168.severity = suggestion
dotnet_diagnostic.RCS1188.severity = error
Expand Down Expand Up @@ -432,15 +425,21 @@ dotnet_diagnostic.SX1101.severity = error
dotnet_diagnostic.SX1309.severity = error
dotnet_diagnostic.SX1623.severity = none

dotnet_diagnostic.IDE0046.severity = suggestion
dotnet_diagnostic.IDE0060.severity = none

# C++ Files
[*.{cpp,h,in}]
curly_bracket_next_line = true
indent_brace_style = Allman

# Xml project files
[*.{csproj,vcxproj,vcxproj.filters,proj,nativeproj,locproj}]
[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,nativeproj,locproj}]
indent_size = 2

[*.{csproj,vbproj,proj,nativeproj,locproj}]
charset = utf-8

# Xml build files
[*.builds]
indent_size = 2
Expand All @@ -453,8 +452,13 @@ indent_size = 2
[*.{props,targets,config,nuspec}]
indent_size = 2

# YAML config files
[*.{yml,yaml}]
indent_size = 2

# Shell scripts
[*.sh]
end_of_line = lf
[*.{cmd, bat}]

[*.{cmd,bat}]
end_of_line = crlf
34 changes: 27 additions & 7 deletions .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,41 @@ jobs:
fetch-depth: 0

- name: Install .NET Core
uses: actions/setup-dotnet@v1
uses: actions/setup-dotnet@v1.8.1
with:
dotnet-version: 3.1.x

- name: Install .NET 5
uses: actions/setup-dotnet@v1
uses: actions/setup-dotnet@v1.8.1
with:
dotnet-version: 5.0.x

- name: Install .NET 6
uses: actions/setup-dotnet@v1.8.1
with:
dotnet-version: 6.0.x
include-prerelease: true

- name: Install DotNet workloads
shell: bash
run: |
dotnet workload install android
dotnet workload install ios
dotnet workload install tvos
dotnet workload install macos
dotnet workload install maui

- name: Install VS2019 preview
shell: bash
run: |
dotnet tool update -g dotnet-vs
vs install preview -sku:enterprise --quiet +Microsoft.VisualStudio.Component.ManagedDesktop.Core +Microsoft.NetCore.Component.DevelopmentTools +Microsoft.VisualStudio.Workload.NetCrossPlat +Microsoft.VisualStudio.Workload.Universal
echo "##vso[task.prependpath]$(vs where preview --prop=InstallationPath)\MSBuild\Current\Bin"

- name: Add MSBuild to PATH
uses: glennawatson/setup-msbuild@v1.0.3

- name: Update VS2019
shell: powershell
run: Start-Process -Wait -PassThru -FilePath "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vs_installer.exe" -ArgumentList "update --passive --norestart --installpath ""C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise"""
with:
prerelease: true

- name: NBGV
id: nbgv
Expand All @@ -48,7 +68,7 @@ jobs:
- name: NuGet Restore
run: dotnet restore
working-directory: src

- name: Build
run: msbuild /t:build,pack /nowarn:MSB4011 /maxcpucount /p:NoPackageAnalysis=true /verbosity:minimal /p:Configuration=${{ env.configuration }}
working-directory: src
Expand Down
37 changes: 33 additions & 4 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
uses: actions/checkout@v2
with:
fetch-depth: 0

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
Expand All @@ -59,13 +59,42 @@ jobs:
# queries: ./path/to/local/query, your-org/your-repo/queries@main


- name: Setup .NET Core
uses: actions/setup-dotnet@v1
- name: Install .NET Core
uses: actions/setup-dotnet@v1.8.1
with:
dotnet-version: 3.1.x

- name: Install .NET 5
uses: actions/setup-dotnet@v1.8.1
with:
dotnet-version: 5.0.x

- name: Install .NET 6
uses: actions/setup-dotnet@v1.8.1
with:
dotnet-version: 5.0.*
dotnet-version: 6.0.x
include-prerelease: true

- name: Install DotNet workloads
shell: bash
run: |
dotnet workload install android
dotnet workload install ios
dotnet workload install tvos
dotnet workload install macos
dotnet workload install maui

- name: Install VS2019 preview
shell: bash
run: |
dotnet tool update -g dotnet-vs
vs install preview -sku:enterprise --quiet +Microsoft.VisualStudio.Component.ManagedDesktop.Core +Microsoft.NetCore.Component.DevelopmentTools +Microsoft.VisualStudio.Workload.NetCrossPlat +Microsoft.VisualStudio.Workload.Universal
echo "##vso[task.prependpath]$(vs where preview --prop=InstallationPath)\MSBuild\Current\Bin"

- name: Add MSBuild to PATH
uses: glennawatson/setup-msbuild@v1.0.3
with:
prerelease: true

- name: NBGV
id: nbgv
Expand Down
14 changes: 13 additions & 1 deletion src/Directory.build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,30 @@
<PropertyGroup Condition="$(TargetFramework.StartsWith('Xamarin.iOS'))">
<DefineConstants>$(DefineConstants);MONO;UIKIT;COCOA;IOS</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="$(TargetFramework.StartsWith('net6.0-ios'))">
<DefineConstants>$(DefineConstants);MONO;UIKIT;COCOA;IOS</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="$(TargetFramework.StartsWith('Xamarin.Mac'))">
<DefineConstants>$(DefineConstants);MONO;COCOA</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="$(TargetFramework.StartsWith('net6.0-macos'))">
<DefineConstants>$(DefineConstants);MONO;COCOA</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="$(TargetFramework.StartsWith('Xamarin.TVOS'))">
<DefineConstants>$(DefineConstants);MONO;UIKIT;COCOA</DefineConstants>
<DefineConstants>$(DefineConstants);MONO;UIKIT;COCOA;TVOS</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="$(TargetFramework.StartsWith('net6.0-tvos'))">
<DefineConstants>$(DefineConstants);MONO;UIKIT;COCOA;TVOS</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="$(TargetFramework.StartsWith('Xamarin.WatchOS'))">
<DefineConstants>$(DefineConstants);MONO;UIKIT;COCOA</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="$(TargetFramework.StartsWith('MonoAndroid'))">
<DefineConstants>$(DefineConstants);MONO;ANDROID</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="$(TargetFramework.StartsWith('net6.0-android'))">
<DefineConstants>$(DefineConstants);MONO;ANDROID</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="$(TargetFramework.StartsWith('tizen'))">
<DefineConstants>$(DefineConstants);TIZEN</DefineConstants>
</PropertyGroup>
Expand Down
4 changes: 2 additions & 2 deletions src/Splat.AppCenter/Splat.AppCenter.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net5.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net5.0;net6.0</TargetFrameworks>
<AssemblyName>Splat.AppCenter</AssemblyName>
<RootNamespace>Splat</RootNamespace>
<Authors>.NET Foundation and Contributors</Authors>
Expand All @@ -15,7 +15,7 @@
<PackageReference Include="Microsoft.AppCenter.Analytics" Version="4.3.0" />
<PackageReference Include="Microsoft.AppCenter.Crashes" Version="4.3.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Splat\Splat.csproj" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net5.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net5.0;net6.0</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">$(TargetFrameworks);net461</TargetFrameworks>
<AssemblyName>Splat.ApplicationInsights</AssemblyName>
<RootNamespace>Splat</RootNamespace>
Expand All @@ -13,7 +13,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.ApplicationInsights" Version="2.18.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Splat\Splat.csproj" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Splat.Autofac/Splat.Autofac.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net5.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net5.0;net6.0</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">$(TargetFrameworks);net461</TargetFrameworks>
<Description>Autofac adapter for Splat</Description>
<LangVersion>latest</LangVersion>
Expand Down
2 changes: 1 addition & 1 deletion src/Splat.Common.Test/Splat.Common.Test.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net5.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net5.0;net6.0</TargetFrameworks>
<NoWarn>$(NoWarn);CA2000</NoWarn>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ public PlatformBitmapLoader()
/// <inheritdoc />
public IBitmap? Create(float width, float height)
{
return Bitmap.CreateBitmap((int)width, (int)height, Bitmap.Config.Argb8888)?.FromNative();
var config = Bitmap.Config.Argb8888 ?? throw new InvalidOperationException("The ARGB8888 bitmap format is unavailable");

return Bitmap.CreateBitmap((int)width, (int)height, config)?.FromNative();
}

internal static Dictionary<string, int> GetDrawableList(IFullLogger? log)
Expand Down Expand Up @@ -147,14 +149,19 @@ private static Type[] GetTypesFromAssembly(

foreach (var loaderException in e.LoaderExceptions)
{
if (loaderException is null)
{
continue;
}

log.Warn(loaderException, "Inner Exception for detecting drawing types.");
}
}

// null check here because mono doesn't appear to follow the MSDN documentation
// as of July 2019.
return e.Types is not null
? e.Types.Where(x => x is not null).ToArray()
? e.Types.Where(x => x is not null).Select(x => x!).ToArray()
: Array.Empty<Type>();
}
}
Expand All @@ -169,6 +176,8 @@ private static Dictionary<string, int> GetDrawableList(
.SelectMany(a => GetTypesFromAssembly(a, log))
.Where(x => x.Name.Equals("Resource", StringComparison.Ordinal) && x.GetNestedType("Drawable") is not null)
.Select(x => x.GetNestedType("Drawable"))
.Where(x => x != null)
.Select(x => x!)
.ToArray();

if (log?.IsDebugEnabled == true)
Expand All @@ -188,7 +197,7 @@ private static Dictionary<string, int> GetDrawableList(
.AsParallel()
.SelectMany(x => x.GetFields())
.Where(x => x.FieldType == typeof(int) && x.IsLiteral)
.ToDictionary(k => k.Name, v => (int)v.GetRawConstantValue());
.ToDictionary(k => k.Name, v => ((int?)v.GetRawConstantValue()) ?? 0);

if (log?.IsDebugEnabled == true)
{
Expand Down
Loading