Skip to content

Commit

Permalink
Feature/blazor wasm skia example (#31)
Browse files Browse the repository at this point in the history
* Example running in Blazor WebAssembly with rendering using SkiaSharp.
  • Loading branch information
highbyte authored Nov 16, 2021
1 parent 301f18a commit ad3ac93
Show file tree
Hide file tree
Showing 30 changed files with 1,331 additions and 6 deletions.
282 changes: 282 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,282 @@
# EditorConfig is awesome: http://EditorConfig.org

# top-most EditorConfig file
root = true

# Don't use tabs for indentation.
[*]
indent_style = space

# Code files
[*.cs]
indent_size = 4
insert_final_newline = true
charset = utf-8
#charset = utf-8-bom

# Xml project files
[*.csproj]
indent_size = 2

# Xml config files
[*.{props,targets}]
indent_size = 2

# Dotnet code style settings:
[*.cs]
# Sort using and Import directives with System.* appearing first
dotnet_sort_system_directives_first = true
dotnet_style_require_accessibility_modifiers = always:warning

# No blank line between System.* and Microsoft.*
dotnet_separate_import_directive_groups = false

# Whitespace options
dotnet_style_allow_multiple_blank_lines_experimental = false
dotnet_style_allow_statement_immediately_after_block_experimental = true
csharp_style_allow_embedded_statements_on_same_line_experimental = true
csharp_style_allow_blank_lines_between_consecutive_braces_experimental = false
csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = false

# dotnet_style_allow_multiple_blank_lines_experimental
dotnet_diagnostic.IDE2000.severity = warning

# csharp_style_allow_embedded_statements_on_same_line_experimental
dotnet_diagnostic.IDE2001.severity = none

# csharp_style_allow_blank_lines_between_consecutive_braces_experimental
dotnet_diagnostic.IDE2002.severity = warning

# dotnet_style_allow_statement_immediately_after_block_experimental
dotnet_diagnostic.IDE2003.severity = suggestion

# csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental
dotnet_diagnostic.IDE2004.severity = warning


# Suggest more modern language features when available
dotnet_style_object_initializer = true:suggestion
dotnet_style_collection_initializer = true:suggestion
dotnet_style_coalesce_expression = true:error
dotnet_style_null_propagation = true:error
dotnet_style_explicit_tuple_names = true:suggestion
dotnet_style_prefer_inferred_tuple_names = true:suggestion
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
dotnet_style_prefer_conditional_expression_over_return = false
dotnet_style_prefer_conditional_expression_over_assignment = false
dotnet_style_prefer_auto_properties = false

# Avoid "this." and "Me." if not necessary
#dotnet_style_qualification_for_field = false:error
#dotnet_style_qualification_for_property = true:error
#dotnet_style_qualification_for_method = false:error
#dotnet_style_qualification_for_event = false:error

# Use language keywords instead of framework type names for type references
dotnet_style_predefined_type_for_locals_parameters_members = true:error
dotnet_style_predefined_type_for_member_access = true:error

# Prefer read-only on fields
dotnet_style_readonly_field = true:warning

# Naming Rules
dotnet_naming_rule.interfaces_must_be_pascal_cased_and_prefixed_with_I.symbols = interface_symbols
dotnet_naming_rule.interfaces_must_be_pascal_cased_and_prefixed_with_I.style = pascal_case_and_prefix_with_I_style
dotnet_naming_rule.interfaces_must_be_pascal_cased_and_prefixed_with_I.severity = warning

dotnet_naming_rule.externally_visible_members_must_be_pascal_cased.symbols = externally_visible_symbols
dotnet_naming_rule.externally_visible_members_must_be_pascal_cased.style = pascal_case_style
dotnet_naming_rule.externally_visible_members_must_be_pascal_cased.severity = warning

dotnet_naming_rule.parameters_must_be_camel_cased.symbols = parameter_symbols
dotnet_naming_rule.parameters_must_be_camel_cased.style = camel_case_style
dotnet_naming_rule.parameters_must_be_camel_cased.severity = warning

dotnet_naming_rule.constants_must_be_pascal_cased.symbols = constant_symbols
dotnet_naming_rule.constants_must_be_pascal_cased.style = pascal_case_style
dotnet_naming_rule.constants_must_be_pascal_cased.severity = warning

dotnet_naming_rule.private_static_fields_must_be_camel_cased_and_prefixed_with_s_underscore.symbols = private_static_field_symbols
dotnet_naming_rule.private_static_fields_must_be_camel_cased_and_prefixed_with_s_underscore.style = camel_case_and_prefix_with_s_underscore_style
dotnet_naming_rule.private_static_fields_must_be_camel_cased_and_prefixed_with_s_underscore.severity = warning

dotnet_naming_rule.private_instance_fields_must_be_camel_cased_and_prefixed_with_underscore.symbols = private_field_symbols
dotnet_naming_rule.private_instance_fields_must_be_camel_cased_and_prefixed_with_underscore.style = camel_case_and_prefix_with_underscore_style
dotnet_naming_rule.private_instance_fields_must_be_camel_cased_and_prefixed_with_underscore.severity = warning

# Symbols
dotnet_naming_symbols.externally_visible_symbols.applicable_kinds = class,struct,interface,enum,property,method,field,event,delegate
dotnet_naming_symbols.externally_visible_symbols.applicable_accessibilities = public,internal,friend,protected,protected_internal,protected_friend,private_protected

dotnet_naming_symbols.interface_symbols.applicable_kinds = interface
dotnet_naming_symbols.interface_symbols.applicable_accessibilities = *

dotnet_naming_symbols.parameter_symbols.applicable_kinds = parameter
dotnet_naming_symbols.parameter_symbols.applicable_accessibilities = *

dotnet_naming_symbols.constant_symbols.applicable_kinds = field
dotnet_naming_symbols.constant_symbols.required_modifiers = const
dotnet_naming_symbols.constant_symbols.applicable_accessibilities = *

dotnet_naming_symbols.private_static_field_symbols.applicable_kinds = field
dotnet_naming_symbols.private_static_field_symbols.required_modifiers = static,shared
dotnet_naming_symbols.private_static_field_symbols.applicable_accessibilities = private

dotnet_naming_symbols.private_field_symbols.applicable_kinds = field
dotnet_naming_symbols.private_field_symbols.applicable_accessibilities = private

# Styles
dotnet_naming_style.camel_case_style.capitalization = camel_case

dotnet_naming_style.pascal_case_style.capitalization = pascal_case

dotnet_naming_style.camel_case_and_prefix_with_s_underscore_style.required_prefix = s_
dotnet_naming_style.camel_case_and_prefix_with_s_underscore_style.capitalization = camel_case

dotnet_naming_style.camel_case_and_prefix_with_underscore_style.required_prefix = _
dotnet_naming_style.camel_case_and_prefix_with_underscore_style.capitalization = camel_case

dotnet_naming_style.pascal_case_and_prefix_with_I_style.required_prefix = I
dotnet_naming_style.pascal_case_and_prefix_with_I_style.capitalization = pascal_case

# CSharp code style settings:
# Prefer "var" only when the type is apparent
csharp_style_var_for_built_in_types = true:silent
csharp_style_var_when_type_is_apparent = true:suggestion
csharp_style_var_elsewhere = true:silent

# Prefer method-like constructs to have a block body
csharp_style_expression_bodied_methods = false:none
csharp_style_expression_bodied_constructors = false:none
csharp_style_expression_bodied_operators = false:none

# Prefer property-like constructs to have an expression-body
csharp_style_expression_bodied_properties = true:none
csharp_style_expression_bodied_indexers = true:none
csharp_style_expression_bodied_accessors = true:none

# Suggest more modern language features when available
csharp_style_pattern_matching_over_is_with_cast_check = true:error
csharp_style_pattern_matching_over_as_with_null_check = true:error
csharp_style_inlined_variable_declaration = true:error
csharp_style_throw_expression = true:suggestion
csharp_style_conditional_delegate_call = true:suggestion
csharp_style_deconstructed_variable_declaration = true:suggestion

# Newline settings
csharp_new_line_before_open_brace = all
csharp_new_line_before_else = true
csharp_new_line_before_catch = true
csharp_new_line_before_finally = true
csharp_new_line_before_members_in_object_initializers = true
csharp_new_line_before_members_in_anonymous_types = true
csharp_new_line_between_query_expression_clauses = true

# Identation options
csharp_indent_case_contents = true
csharp_indent_case_contents_when_block = false
csharp_indent_switch_labels = true
csharp_indent_labels = no_change
csharp_indent_block_contents = true
csharp_indent_braces = false

# Spacing options
csharp_space_after_cast = false
csharp_space_after_keywords_in_control_flow_statements = true
csharp_space_between_method_call_empty_parameter_list_parentheses = false
csharp_space_between_method_call_parameter_list_parentheses = false
csharp_space_between_method_call_name_and_opening_parenthesis = false
csharp_space_between_method_declaration_parameter_list_parentheses = false
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
csharp_space_between_method_declaration_parameter_list_parentheses = false
csharp_space_between_method_declaration_name_and_open_parenthesis = false
csharp_space_between_parentheses = false
csharp_space_between_square_brackets = false
csharp_space_between_empty_square_brackets = false
csharp_space_before_open_square_brackets = false
csharp_space_around_declaration_statements = false
csharp_space_around_binary_operators = before_and_after
csharp_space_after_cast = false
csharp_space_before_semicolon_in_for_statement = false
csharp_space_before_dot = false
csharp_space_after_dot = false
csharp_space_before_comma = false
csharp_space_after_comma = true
csharp_space_before_colon_in_inheritance_clause = true
csharp_space_after_colon_in_inheritance_clause = true
csharp_space_after_semicolon_in_for_statement = true

# Wrapping
csharp_preserve_single_line_statements = true
csharp_preserve_single_line_blocks = true

# Code block
csharp_prefer_braces = when_multiline:warning


# -----------------------------------------------
# Misc Code Styles that should affect code analysis
# -----------------------------------------------
# IDE0005: Using directive is unnecessary.
dotnet_diagnostic.IDE0005.severity = warning

# IDE0051: Remove unused private members
dotnet_diagnostic.IDE0051.severity = warning

# IDE0052: Remove unread private members
dotnet_diagnostic.IDE0052.severity = warning

# IDE0054: Use compound assignment
dotnet_style_prefer_compound_assignment = false:suggestion

# IDE0055: Fix formatting. All formatting options have rule ID IDE0055 and title Fix formatting
dotnet_diagnostic.IDE0055.severity = warning


# -----------------------------------------------
# Misc Code Rules that should be disabled in code analysis
# -----------------------------------------------

# CA1303: Do not pass literals as localized parameters
#dotnet_diagnostic.CA1303.severity = none

# CA1812: An internal class that is apparently never instantiated. If so, remove the code from the assembly. If this class is intended to contain only static members, make it static (Shared in Visual Basic).
#dotnet_diagnostic.CA1812.severity = none

# CA1707: Identifiers should not contain underscores
#dotnet_diagnostic.CA1707.severity = none

# CA1062: Validate arguments of public methods
#dotnet_diagnostic.CA1062.severity = none

# CA1710: Identifiers should have correct suffix
#dotnet_diagnostic.CA1710.severity = none

# Don't use keywords
#dotnet_diagnostic.CA1716.severity = none

# CA1063: Implement IDisposable Correctly
#dotnet_diagnostic.CA1063.severity = none

# CA1816: Dispose methods should call SuppressFinalize
#dotnet_diagnostic.CA1816.severity = none

# CA1305: Specify IFormatProvider
#dotnet_diagnostic.CA1305.severity = none

# CA1308: Normalize strings to uppercase
#dotnet_diagnostic.CA1308.severity = none

# CA1307: Specify StringComparison
#dotnet_diagnostic.CA1307.severity = none

# CA1030: Use events where appropriate
#dotnet_diagnostic.CA1030.severity = none

#dotnet_diagnostic.CA1062.severity = none
#dotnet_diagnostic.CS1591.severity = none
#dotnet_diagnostic.CS1573.severity = none

# CA1724: Type names should not match namespaces
#dotnet_diagnostic.CA1724.severity = none
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ on:

env:
CONFIGURATION: "Release"
PROJECT_FILE: "Examples/BlazorWasmTest/BlazorWasmTest.csproj"
#PROJECT_FILE: "Examples/BlazorWasmTest/BlazorWasmTest.csproj"
PROJECT_FILE: "Examples/BlazorWasmSkiaTest/BlazorWasmSkiaTest.csproj"
PROJECT_GH_PAGES_DIR: "blazorexample"
BUILD_OUTPUT_WORKING_DIR: "build"
GH_PAGES_WORKING_DIR: "ghpages"
Expand All @@ -27,6 +28,10 @@ jobs:
with:
dotnet-version: 6.0.x

- name: Install DotNet workload - WASM tools
run: |
dotnet workload install wasm-tools
# Create GitHub Pages root folder contents
- name: Create GH root folder and add .nojekyll file do disable built-in Jekyll CMS
run: |
Expand Down
12 changes: 12 additions & 0 deletions Examples/BlazorWasmSkiaTest/App.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Router AppAssembly="@typeof(App).Assembly">
<Found Context="routeData">
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
<FocusOnNavigate RouteData="@routeData" Selector="h1" />
</Found>
<NotFound>
<PageTitle>Not found</PageTitle>
<LayoutView Layout="@typeof(MainLayout)">
<p role="alert">Sorry, there's nothing at this address.</p>
</LayoutView>
</NotFound>
</Router>
42 changes: 42 additions & 0 deletions Examples/BlazorWasmSkiaTest/BlazorWasmSkiaTest.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>

<RunAOTCompilation>true</RunAOTCompilation>

<!--<PublishIISAssets>true</PublishIISAssets>-->

<!--<BlazorEnableTimeZoneSupport>false</BlazorEnableTimeZoneSupport>
<BlazorWebAssemblyPreserveCollationData>false</BlazorWebAssemblyPreserveCollationData>-->

</PropertyGroup>

<!--In debug, make builds faster by reducing optimizations-->
<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
<WasmNativeStrip>false</WasmNativeStrip>
<EmccCompileOptimizationFlag>-O1</EmccCompileOptimizationFlag>
</PropertyGroup>
<ItemGroup>
<Content Remove="wwwroot\fonts\C64_Pro_Mono-STYLE.ttf" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Resources\Fonts\C64_Pro_Mono-STYLE.ttf" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\Highbyte.DotNet6502\Highbyte.DotNet6502.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="6.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="6.0.0" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.WebUtilities" Version="2.2.0" />
<PackageReference Include="SkiaSharp.Views.Blazor" Version="2.88.0-preview.155" />
<PackageReference Include="PublishSPAforGitHubPages.Build" Version="1.3.2" />
<PackageReference Include="System.Net.Http.Json" Version="6.0.0" />
</ItemGroup>

</Project>
25 changes: 25 additions & 0 deletions Examples/BlazorWasmSkiaTest/BlazorWasmSkiaTest.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazorWasmSkiaTest", "BlazorWasmSkiaTest.csproj", "{41C81D23-C130-47DC-B741-4F4D134CE003}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{41C81D23-C130-47DC-B741-4F4D134CE003}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{41C81D23-C130-47DC-B741-4F4D134CE003}.Debug|Any CPU.Build.0 = Debug|Any CPU
{41C81D23-C130-47DC-B741-4F4D134CE003}.Release|Any CPU.ActiveCfg = Release|Any CPU
{41C81D23-C130-47DC-B741-4F4D134CE003}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {60EEAAA6-9D93-4957-9663-11304A1550A8}
EndGlobalSection
EndGlobal
Loading

0 comments on commit ad3ac93

Please sign in to comment.