diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..083e33d --- /dev/null +++ b/.editorconfig @@ -0,0 +1,248 @@ +# To learn more about .editorconfig see https://aka.ms/editorconfigdocs + +# Visual Studio Default Template + +# Additions / Modifications +# Style Definitions taken from https://github.com/dotnet/roslyn/blob/master/.editorconfig +# indent_style = tab +# dotnet_style_qualification_for_field = true:silent +# Merge static_fields and instance_fields naming rule and remove prefix +# csharp_style_var_for_built_in_types = false:silent +# csharp_style_var_when_type_is_apparent = false:silent +# csharp_style_var_elsewhere = false:silent +# csharp_style_expression_bodied_methods = when_on_single_line:silent + +# top-most EditorConfig file +root = true + +[*] +indent_style = tab +# (Please don't specify an indent_size here; that has too many unintended consequences.) + +# Code files +[*.{cs,csx,vb,vbx}] +indent_size = 4 +insert_final_newline = false +charset = utf-8-bom + +# XML project files +[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj}] +indent_size = 2 + +# XML config files +[*.{props,targets,ruleset,config,nuspec,resx,vsixmanifest,vsct}] +indent_size = 2 + +# JSON files +[*.json] +indent_size = 2 + +# Powershell files +[*.ps1] +indent_size = 2 + +# Shell script files +[*.sh] +end_of_line = lf +indent_size = 2 + +# Dotnet code style settings: +[*.{cs,vb}] + +############################### +# .NET Coding Conventions # +############################### +[*.{cs,vb}] +# Organize usings +dotnet_sort_system_directives_first = true +# this. preferences +dotnet_style_qualification_for_field = true:silent +dotnet_style_qualification_for_property = false:silent +dotnet_style_qualification_for_method = false:silent +dotnet_style_qualification_for_event = false:silent +# Language keywords vs BCL types preferences +dotnet_style_predefined_type_for_locals_parameters_members = true:silent +dotnet_style_predefined_type_for_member_access = true:silent +# Parentheses preferences +dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:silent +dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:silent +dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:silent +dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent +# Modifier preferences +dotnet_style_require_accessibility_modifiers = for_non_interface_members:silent +dotnet_style_readonly_field = true: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_null_propagation = true:suggestion +dotnet_style_coalesce_expression = true:suggestion +dotnet_style_prefer_is_null_check_over_reference_equality_method = true:silent +dotnet_style_prefer_inferred_tuple_names = true:suggestion +dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion +dotnet_style_prefer_auto_properties = true:silent +dotnet_style_prefer_conditional_expression_over_assignment = true:silent +dotnet_style_prefer_conditional_expression_over_return = true:silent +############################### +# Naming Conventions # +############################### +# Style Definitions + +# Non-private static fields are PascalCase +dotnet_naming_rule.non_private_static_fields_should_be_pascal_case.severity = suggestion +dotnet_naming_rule.non_private_static_fields_should_be_pascal_case.symbols = non_private_static_fields +dotnet_naming_rule.non_private_static_fields_should_be_pascal_case.style = non_private_static_field_style + +dotnet_naming_symbols.non_private_static_fields.applicable_kinds = field +dotnet_naming_symbols.non_private_static_fields.applicable_accessibilities = public, protected, internal, protected_internal, private_protected +dotnet_naming_symbols.non_private_static_fields.required_modifiers = static + +dotnet_naming_style.non_private_static_field_style.capitalization = pascal_case + +# Non-private readonly fields are PascalCase +dotnet_naming_rule.non_private_readonly_fields_should_be_pascal_case.severity = suggestion +dotnet_naming_rule.non_private_readonly_fields_should_be_pascal_case.symbols = non_private_readonly_fields +dotnet_naming_rule.non_private_readonly_fields_should_be_pascal_case.style = non_private_readonly_field_style + +dotnet_naming_symbols.non_private_readonly_fields.applicable_kinds = field +dotnet_naming_symbols.non_private_readonly_fields.applicable_accessibilities = public, protected, internal, protected_internal, private_protected +dotnet_naming_symbols.non_private_readonly_fields.required_modifiers = readonly + +dotnet_naming_style.non_private_readonly_field_style.capitalization = pascal_case + +# Constants are PascalCase +dotnet_naming_rule.constants_should_be_pascal_case.severity = suggestion +dotnet_naming_rule.constants_should_be_pascal_case.symbols = constants +dotnet_naming_rule.constants_should_be_pascal_case.style = constant_style + +dotnet_naming_symbols.constants.applicable_kinds = field, local +dotnet_naming_symbols.constants.required_modifiers = const + +dotnet_naming_style.constant_style.capitalization = pascal_case + +# Fields are camelCase +dotnet_naming_rule.fields_should_be_camel_case.severity = suggestion +dotnet_naming_rule.fields_should_be_camel_case.symbols = fields +dotnet_naming_rule.fields_should_be_camel_case.style = fields_style + +dotnet_naming_symbols.fields.applicable_kinds = field +dotnet_naming_symbols.fields.required_modifiers = static + +dotnet_naming_style.fields_style.capitalization = camel_case + +# Locals and parameters are camelCase +dotnet_naming_rule.locals_should_be_camel_case.severity = suggestion +dotnet_naming_rule.locals_should_be_camel_case.symbols = locals_and_parameters +dotnet_naming_rule.locals_should_be_camel_case.style = camel_case_style + +dotnet_naming_symbols.locals_and_parameters.applicable_kinds = parameter, local + +dotnet_naming_style.camel_case_style.capitalization = camel_case + +# Local functions are PascalCase +dotnet_naming_rule.local_functions_should_be_pascal_case.severity = suggestion +dotnet_naming_rule.local_functions_should_be_pascal_case.symbols = local_functions +dotnet_naming_rule.local_functions_should_be_pascal_case.style = local_function_style + +dotnet_naming_symbols.local_functions.applicable_kinds = local_function + +dotnet_naming_style.local_function_style.capitalization = pascal_case + +# By default, name items with PascalCase +dotnet_naming_rule.members_should_be_pascal_case.severity = suggestion +dotnet_naming_rule.members_should_be_pascal_case.symbols = all_members +dotnet_naming_rule.members_should_be_pascal_case.style = pascal_case_style + +dotnet_naming_symbols.all_members.applicable_kinds = * + + +############################### +# C# Coding Conventions # +############################### +[*.cs] +# Indentation preferences +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 = flush_left +# var preferences +csharp_style_var_for_built_in_types = false:silent +csharp_style_var_when_type_is_apparent = false:silent +csharp_style_var_elsewhere = false:silent +# Expression-bodied members +csharp_style_expression_bodied_methods = when_on_single_line:silent +csharp_style_expression_bodied_constructors = false:silent +csharp_style_expression_bodied_operators = false:silent +csharp_style_expression_bodied_properties = true:silent +csharp_style_expression_bodied_indexers = true:silent +csharp_style_expression_bodied_accessors = true:silent +# Pattern matching preferences +csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion +csharp_style_pattern_matching_over_as_with_null_check = true:suggestion +# Null-checking preferences +csharp_style_throw_expression = true:suggestion +csharp_style_conditional_delegate_call = true:suggestion +# Modifier preferences +csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:suggestion +# Expression-level preferences +csharp_prefer_braces = true:silent +csharp_style_deconstructed_variable_declaration = true:suggestion +csharp_prefer_simple_default_expression = true:suggestion +csharp_style_pattern_local_over_anonymous_function = true:suggestion +csharp_style_inlined_variable_declaration = true:suggestion +############################### +# C# Formatting Rules # +############################### +# New line preferences +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 +# Indentation preferences +csharp_indent_case_contents = true +csharp_indent_switch_labels = true +csharp_indent_labels = flush_left +# Space preferences +csharp_space_after_cast = false +csharp_space_after_keywords_in_control_flow_statements = true +csharp_space_between_method_call_parameter_list_parentheses = false +csharp_space_between_method_declaration_parameter_list_parentheses = false +csharp_space_between_parentheses = false +csharp_space_before_colon_in_inheritance_clause = true +csharp_space_after_colon_in_inheritance_clause = true +csharp_space_around_binary_operators = before_and_after +csharp_space_between_method_declaration_empty_parameter_list_parentheses = false +csharp_space_between_method_call_name_and_opening_parenthesis = false +csharp_space_between_method_call_empty_parameter_list_parentheses = false +# Wrapping preferences +csharp_preserve_single_line_statements = true +csharp_preserve_single_line_blocks = true + +# StyleCop.Analyzers + +# SA1101: Prefix local calls with this +dotnet_diagnostic.SA1101.severity = none +# SA1116: Split parameters should start on line after declaration +dotnet_diagnostic.SA1116.severity = none +# SA1117: Parameters should be on same line or separate lines +dotnet_diagnostic.SA1117.severity = none +# SA1127: Generic type constraints should be on their own line +dotnet_diagnostic.SA1127.severity = none +# SA1128: Put constructor initializers on their own line +dotnet_diagnostic.SA1128.severity = none +# SA1600: Elements should be documented +dotnet_diagnostic.SA1600.severity = none +# SA1601: Partial elements should be documented +dotnet_diagnostic.SA1601.severity = none +# SA1602: Enumeration items should be documented +dotnet_diagnostic.SA1602.severity = none + +# FxCopAnalyzers + +# CA1303: Do not pass literals as localized parameters +dotnet_diagnostic.CA1303.severity = none \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..910bfc4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,371 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ +[Ll]ogs/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Coverlet is a free, cross platform Code Coverage Tool +coverage*[.json, .xml, .info] + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd + +## Added from https://github.com/xamarin/xamarin-forms-samples/blob/master/.gitignore + +# ignore Xamarin.Android Resource.Designer.cs files +**/*.Droid/**/[Rr]esource.[Dd]esigner.cs +**/*.Android/**/[Rr]esource.[Dd]esigner.cs +**/Android/**/[Rr]esource.[Dd]esigner.cs +**/Droid/**/[Rr]esource.[Dd]esigner.cs + +# Xamarin Components +Components/ \ No newline at end of file diff --git a/Directory.Build.props b/Directory.Build.props new file mode 100644 index 0000000..205d449 --- /dev/null +++ b/Directory.Build.props @@ -0,0 +1,6 @@ + + + true + $(NoWarn);1591 + + \ No newline at end of file diff --git a/Directory.Build.targets b/Directory.Build.targets new file mode 100644 index 0000000..2bad34a --- /dev/null +++ b/Directory.Build.targets @@ -0,0 +1,12 @@ + + + + + + + + + stylecop.json + + + \ No newline at end of file diff --git a/FocusInit.sln b/FocusInit.sln new file mode 100644 index 0000000..b720cb6 --- /dev/null +++ b/FocusInit.sln @@ -0,0 +1,42 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30011.22 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{8a94c1bf-0475-4920-8989-695d63cf2817}" + ProjectSection(SolutionItems) = preProject + .editorconfig = .editorconfig + .gitignore = .gitignore + Directory.Build.props = Directory.Build.props + Directory.Build.targets = Directory.Build.targets + README.md = README.md + LICENSE = LICENSE + FocusInit.sln.DotSettings = FocusInit.sln.DotSettings + stylecop.json = stylecop.json + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{84322B48-B33E-4C21-88B2-22A7FE4289FB}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FocusInit", "src\FocusInit\FocusInit.csproj", "{4316E4B6-DB86-4415-A751-BAACD4635B8A}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {4316E4B6-DB86-4415-A751-BAACD4635B8A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4316E4B6-DB86-4415-A751-BAACD4635B8A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4316E4B6-DB86-4415-A751-BAACD4635B8A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4316E4B6-DB86-4415-A751-BAACD4635B8A}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {BD6C0DE4-F249-4C4D-9BBA-B3CDAD08EADB} + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {4316E4B6-DB86-4415-A751-BAACD4635B8A} = {84322B48-B33E-4C21-88B2-22A7FE4289FB} + EndGlobalSection +EndGlobal diff --git a/FocusInit.sln.DotSettings b/FocusInit.sln.DotSettings new file mode 100644 index 0000000..02fca77 --- /dev/null +++ b/FocusInit.sln.DotSettings @@ -0,0 +1,219 @@ + + + <?xml version="1.0" encoding="utf-16"?><Profile name="Default"><XMLReformatCode>True</XMLReformatCode><CSCodeStyleAttributes ArrangeTypeAccessModifier="True" ArrangeTypeMemberAccessModifier="True" SortModifiers="True" RemoveRedundantParentheses="True" AddMissingParentheses="True" ArrangeBraces="True" ArrangeAttributes="True" ArrangeArgumentsStyle="True" ArrangeCodeBodyStyle="False" ArrangeVarStyle="True" /><JsReformatCode>True</JsReformatCode><HtmlReformatCode>True</HtmlReformatCode><CssReformatCode>True</CssReformatCode><CSOptimizeUsings><OptimizeUsings>True</OptimizeUsings><EmbraceInRegion>False</EmbraceInRegion><RegionName></RegionName></CSOptimizeUsings><CSReformatCode>True</CSReformatCode><CSReorderTypeMembers>True</CSReorderTypeMembers><CSUpdateFileHeader>True</CSUpdateFileHeader><CSUseAutoProperty>True</CSUseAutoProperty><CSMakeFieldReadonly>True</CSMakeFieldReadonly><CSMakeAutoPropertyGetOnly>True</CSMakeAutoPropertyGetOnly><CSArrangeQualifiers>True</CSArrangeQualifiers><CSFixBuiltinTypeReferences>True</CSFixBuiltinTypeReferences><CSShortenReferences>True</CSShortenReferences><CSharpFormatDocComments>True</CSharpFormatDocComments><JsInsertSemicolon>True</JsInsertSemicolon><CssAlphabetizeProperties>True</CssAlphabetizeProperties><FormatAttributeQuoteDescriptor>True</FormatAttributeQuoteDescriptor></Profile> + Default + Required + Required + Required + Required + ExpressionBody + Field, Property, Event, Method + Field + False + USE_TABS_ONLY + 1 + 1 + 1 + 1 + 1 + 1 + 1 + False + False + False + False + NEVER + NEVER + NEVER + True + False + True + False + CHOP_IF_LONG + 140 + CHOP_ALWAYS + USE_TABS_ONLY + 1 + True + OneStep + True + True + True + OneStep + OnSingleLine + True + USE_TABS_ONLY + 1 + OneStep + OnSingleLine + True + OneStep + OnSingleLine + <?xml version="1.0" encoding="utf-16"?> +<Patterns xmlns="urn:schemas-jetbrains-com:member-reordering-patterns"> + <TypePattern DisplayName="Non-reorderable types"> + <TypePattern.Match> + <Or> + <And> + <Kind Is="Interface" /> + <Or> + <HasAttribute Name="System.Runtime.InteropServices.InterfaceTypeAttribute" /> + <HasAttribute Name="System.Runtime.InteropServices.ComImport" /> + </Or> + </And> + <Kind Is="Struct" /> + <HasAttribute Name="JetBrains.Annotations.NoReorderAttribute" /> + <HasAttribute Name="JetBrains.Annotations.NoReorder" /> + </Or> + </TypePattern.Match> + </TypePattern> + <TypePattern DisplayName="xUnit.net Test Classes" RemoveRegions="All"> + <TypePattern.Match> + <And> + <Kind Is="Class" /> + <HasMember> + <And> + <Kind Is="Method" /> + <HasAttribute Name="Xunit.FactAttribute" Inherited="True" /> + </And> + </HasMember> + </And> + </TypePattern.Match> + <Entry DisplayName="Setup/Teardown Methods"> + <Entry.Match> + <Or> + <Kind Is="Constructor" /> + <And> + <Kind Is="Method" /> + <ImplementsInterface Name="System.IDisposable" /> + </And> + </Or> + </Entry.Match> + <Entry.SortBy> + <Kind Order="Constructor" /> + </Entry.SortBy> + </Entry> + <Entry DisplayName="All other members" /> + <Entry Priority="100" DisplayName="Test Methods"> + <Entry.Match> + <And> + <Kind Is="Method" /> + <HasAttribute Name="Xunit.FactAttribute" /> + </And> + </Entry.Match> + <Entry.SortBy> + <Name /> + </Entry.SortBy> + </Entry> + </TypePattern> + <TypePattern DisplayName="NUnit Test Fixtures" RemoveRegions="All"> + <TypePattern.Match> + <And> + <Kind Is="Class" /> + <HasAttribute Name="NUnit.Framework.TestFixtureAttribute" Inherited="True" /> + </And> + </TypePattern.Match> + <Entry DisplayName="Setup/Teardown Methods"> + <Entry.Match> + <And> + <Kind Is="Method" /> + <Or> + <HasAttribute Name="NUnit.Framework.SetUpAttribute" Inherited="True" /> + <HasAttribute Name="NUnit.Framework.TearDownAttribute" Inherited="True" /> + <HasAttribute Name="NUnit.Framework.FixtureSetUpAttribute" Inherited="True" /> + <HasAttribute Name="NUnit.Framework.FixtureTearDownAttribute" Inherited="True" /> + </Or> + </And> + </Entry.Match> + </Entry> + <Entry DisplayName="All other members" /> + <Entry Priority="100" DisplayName="Test Methods"> + <Entry.Match> + <And> + <Kind Is="Method" /> + <HasAttribute Name="NUnit.Framework.TestAttribute" /> + </And> + </Entry.Match> + <Entry.SortBy> + <Name /> + </Entry.SortBy> + </Entry> + </TypePattern> + <TypePattern DisplayName="Default Pattern"> + <Entry DisplayName="All Members"> + <Entry.SortBy> + <Kind Order="Constant Field Constructor Destructor Delegate Event Enum Interface Property Indexer Operator Method Struct Class" /> + <Access Order="Public Protected Internal Private" /> + <Static /> + <Readonly /> + <Name /> + </Entry.SortBy> + </Entry> + </TypePattern> +</Patterns> + True + True + UseExplicitType + UseExplicitType + UseExplicitType + <copyright file="$FILENAME$" company="Spatial Focus GmbH"> +Copyright (c) Spatial Focus GmbH. All rights reserved. +</copyright> + <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> + <Policy Inspect="True" Prefix="I" Suffix="" Style="AaBb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> + <Policy Inspect="True" Prefix="T" Suffix="" Style="AaBb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> + True + True + True + True + True + True + True + True + True + True + True + True + True + True + \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..e293fa2 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020 Spatial Focus + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..3e4d23d --- /dev/null +++ b/README.md @@ -0,0 +1,7 @@ +# FocusInit + + + +---- + +Made with :heart: by [Spatial Focus](https://spatial-focus.net/) \ No newline at end of file diff --git a/src/FocusInit/DotnetCliHelper.cs b/src/FocusInit/DotnetCliHelper.cs new file mode 100644 index 0000000..3d5e7ec --- /dev/null +++ b/src/FocusInit/DotnetCliHelper.cs @@ -0,0 +1,51 @@ +// +// Copyright (c) Spatial Focus GmbH. All rights reserved. +// + +namespace FocusInit +{ + using System.Diagnostics; + + public class DotnetCliHelper + { + public DotnetCliHelper(string workDir, string solutionName) + { + WorkDir = workDir; + SolutionName = solutionName; + } + + protected string SolutionName { get; } + + protected string WorkDir { get; } + + public void AddProjectToSolution(string projectPath) + { + string solutionFolder = !string.IsNullOrEmpty(WorkDir) ? WorkDir + "/" : string.Empty; + string solutionFileName = SolutionName + ".sln"; + + string addToSolutionCmd = $"sln {solutionFolder}{solutionFileName} add {projectPath}"; + Process process = Process.Start("dotnet", addToSolutionCmd); + + process.WaitForExit(3000); + } + + public void AddReferenceToProject(string projectPath, string referenceProjectPath) + { + string addReferenceCmd = $"add {projectPath} reference {referenceProjectPath}"; + Process process = Process.Start("dotnet", addReferenceCmd); + process.WaitForExit(3000); + } + + public string CreateProject(string type, string projectSuffix) + { + string srcFolder = !string.IsNullOrEmpty(WorkDir) ? WorkDir + "/src" : "src"; + + string createProjectCmd = $"new {type} -n {SolutionName}.{projectSuffix} -o {srcFolder}/{SolutionName}.{projectSuffix}"; + Process process = Process.Start("dotnet", createProjectCmd); + + process.WaitForExit(3000); + + return $"{srcFolder}/{SolutionName}.{projectSuffix}"; + } + } +} \ No newline at end of file diff --git a/src/FocusInit/FileSystemHelper.cs b/src/FocusInit/FileSystemHelper.cs new file mode 100644 index 0000000..d5e5bc1 --- /dev/null +++ b/src/FocusInit/FileSystemHelper.cs @@ -0,0 +1,48 @@ +// +// Copyright (c) Spatial Focus GmbH. All rights reserved. +// + +namespace FocusInit +{ + using System.IO; + + public class FileSystemHelper + { + public void CleanupAndCreateWorkDir() + { + if (Directory.Exists(Settings.WorkingDir)) + { + // Deal with readonly files (typically in .git folder) + SetDirectoryNormal(Settings.WorkingDir); + Directory.Delete(Settings.WorkingDir, true); + } + + Directory.CreateDirectory(Settings.WorkingDir); + } + + public void DeleteRepository() + { + if (Directory.Exists(Settings.RepoDir)) + { + // Deal with readonly files (typically in .git folder) + SetDirectoryNormal(Settings.RepoDir); + Directory.Delete(Settings.RepoDir, true); + } + } + + private void SetDirectoryNormal(string dir) + { + foreach (string subDir in Directory.GetDirectories(dir)) + { + SetDirectoryNormal(subDir); + + DirectoryInfo subDirectory = new DirectoryInfo(subDir) { Attributes = FileAttributes.Normal }; + + foreach (FileInfo file in subDirectory.GetFiles()) + { + file.Attributes = FileAttributes.Normal; + } + } + } + } +} \ No newline at end of file diff --git a/src/FocusInit/FocusInit.csproj b/src/FocusInit/FocusInit.csproj new file mode 100644 index 0000000..37e02d8 --- /dev/null +++ b/src/FocusInit/FocusInit.csproj @@ -0,0 +1,36 @@ + + + + Exe + netcoreapp3.1 + + true + focus-init + ./nupkg + + 0.1.1 + SpatialFocus.FocusInit + Spatial Focus initialize project wizard + DotNet Tool for initializing an empty folder, create a solution with stylecop, ReSharper and license settings, and optionally add projects. + tool, scaffolding, code-style, code-quality + https://github.com/SpatialFocus/SpatialFocus.FocusInit + MIT + git + https://github.com/SpatialFocus/SpatialFocus.FocusInit.git + pergerch,Dresel + SpatialFocus + True + + + + + + + + + + + + + + diff --git a/src/FocusInit/Program.cs b/src/FocusInit/Program.cs new file mode 100644 index 0000000..1970ba2 --- /dev/null +++ b/src/FocusInit/Program.cs @@ -0,0 +1,152 @@ +// +// Copyright (c) Spatial Focus GmbH. All rights reserved. +// + +namespace FocusInit +{ + using System; + using System.Collections.Generic; + using System.IO; + using LibGit2Sharp; + using McMaster.Extensions.CommandLineUtils; + + public static class Program + { + public static void Main() + { + FileSystemHelper fileSystemHelper = new FileSystemHelper(); + + if (!string.IsNullOrEmpty(Settings.WorkingDir)) + { + fileSystemHelper.CleanupAndCreateWorkDir(); + } + + Console.WriteLine("Welcome to focus-init"); + Console.WriteLine(); + Console.WriteLine("Initialize this folder for a new project."); + + string currentDirectoryName = new DirectoryInfo(Directory.GetCurrentDirectory()).Name; + string solutionName = Prompt.GetString("Enter solution name", currentDirectoryName, ConsoleColor.DarkCyan); + string companyName = Prompt.GetString("Enter company name", Settings.DefaultCompany, ConsoleColor.DarkCyan); + Repository.Clone(Settings.RepoUrl, Settings.RepoDir); + + Console.WriteLine("Template repository cloned."); + + SolutionFilesHelper solutionFilesHelper = new SolutionFilesHelper(solutionName); + solutionFilesHelper.InitializeSolution(solutionName); + solutionFilesHelper.InitializeDotSettings(solutionName, companyName); + solutionFilesHelper.InitializeStylecop(companyName); + solutionFilesHelper.InitializeReadme(solutionName, companyName); + solutionFilesHelper.CopyRemainingFiles(); + + Console.WriteLine("Solution files have been copied and modified."); + + fileSystemHelper.DeleteRepository(); + + bool createProjects = Prompt.GetYesNo("Create additional projects?", true, ConsoleColor.DarkCyan); + + if (createProjects) + { + Program.CreateProjects(solutionName); + } + + Console.WriteLine("Finished. Have fun!"); + } + + private static void CreateProjects(string solutionName) + { + DotnetCliHelper cliHelper = new DotnetCliHelper(Settings.WorkingDir, solutionName); + int i; + + do + { + Console.WriteLine(" 1) Console app"); + Console.WriteLine(" 2) Empty web"); + Console.WriteLine(" 3) Web API"); + Console.WriteLine(" 4) Web MVC"); + Console.WriteLine(" 5) Xamarin Forms Shell (coming soon)"); + Console.WriteLine(" 6) Blazor Server"); + Console.WriteLine(" 7) Blazor Wasm"); + i = Prompt.GetInt("Select project type", null, ConsoleColor.DarkCyan); + } + while (i <= 0 || i > 7); + + List createdProjects = new List(); + + switch (i) + { + case 1: + string consoleProject = cliHelper.CreateProject("console", "Console"); + cliHelper.AddProjectToSolution(consoleProject); + createdProjects.Add(consoleProject); + break; + case 2: + string emptyWebProject = cliHelper.CreateProject("web", "Web"); + cliHelper.AddProjectToSolution(emptyWebProject); + createdProjects.Add(emptyWebProject); + break; + case 3: + string webApiProject = cliHelper.CreateProject("webapi", "Web"); + cliHelper.AddProjectToSolution(webApiProject); + createdProjects.Add(webApiProject); + break; + case 4: + string mvcProject = cliHelper.CreateProject("mvc", "Web"); + cliHelper.AddProjectToSolution(mvcProject); + createdProjects.Add(mvcProject); + break; + case 5: + // TODO + return; + case 6: + string blazorProject = cliHelper.CreateProject("blazorserver", "Blazor"); + cliHelper.AddProjectToSolution(blazorProject); + createdProjects.Add(blazorProject); + break; + case 7: + string wasmProject = cliHelper.CreateProject("blazorwasm", "Blazor"); + cliHelper.AddProjectToSolution(wasmProject); + createdProjects.Add(wasmProject); + break; + } + + if (Prompt.GetYesNo("Create business project?", false, ConsoleColor.DarkCyan)) + { + string businessProject = cliHelper.CreateProject("classlib", "Business"); + + cliHelper.AddProjectToSolution(businessProject); + + foreach (string project in createdProjects) + { + cliHelper.AddReferenceToProject(project, businessProject); + } + + createdProjects.Add(businessProject); + } + + if (Prompt.GetYesNo("Create shared project?", false, ConsoleColor.DarkCyan)) + { + string sharedProject = cliHelper.CreateProject("classlib", "Shared"); + + cliHelper.AddProjectToSolution(sharedProject); + + foreach (string project in createdProjects) + { + cliHelper.AddReferenceToProject(project, sharedProject); + } + } + + if (Prompt.GetYesNo("Create test project?", false, ConsoleColor.DarkCyan)) + { + string testProject = cliHelper.CreateProject("nunit", "Test"); + + cliHelper.AddProjectToSolution(testProject); + + foreach (string project in createdProjects) + { + cliHelper.AddReferenceToProject(testProject, project); + } + } + } + } +} \ No newline at end of file diff --git a/src/FocusInit/Settings.cs b/src/FocusInit/Settings.cs new file mode 100644 index 0000000..4c8465d --- /dev/null +++ b/src/FocusInit/Settings.cs @@ -0,0 +1,26 @@ +// +// Copyright (c) Spatial Focus GmbH. All rights reserved. +// + +namespace FocusInit +{ + using System.IO; + + public static class Settings + { + // Create a subfolder for debug purposes +#if DEBUG + public const string WorkingDir = "SubDirectory"; +#else + public const string WorkingDir = ""; +#endif + + public const string DefaultCompany = "Spatial Focus GmbH"; + + public const string DefaultCompanyTag = "[Spatial Focus](https://spatial-focus.net/)"; + + public const string RepoUrl = "https://github.com/SpatialFocus/repository-template"; + + public static string RepoDir => Path.Combine(Settings.WorkingDir, "repo"); + } +} \ No newline at end of file diff --git a/src/FocusInit/SolutionFilesHelper.cs b/src/FocusInit/SolutionFilesHelper.cs new file mode 100644 index 0000000..c9e81a3 --- /dev/null +++ b/src/FocusInit/SolutionFilesHelper.cs @@ -0,0 +1,87 @@ +// +// Copyright (c) Spatial Focus GmbH. All rights reserved. +// + +namespace FocusInit +{ + using System; + using System.IO; + + public class SolutionFilesHelper + { + public SolutionFilesHelper(string solutionName) + { + SolutionName = solutionName; + } + + protected string SolutionName { get; } + + public void CopyRemainingFiles() + { + string[] fileNames = new[] { ".editorconfig", ".gitignore", "Directory.Build.props", "Directory.Build.targets" }; + + foreach (string fileName in fileNames) + { + File.Copy(Path.Combine(Settings.RepoDir, fileName), Path.Combine(Settings.WorkingDir, fileName)); + } + } + + public void InitializeDotSettings(string solutionName, string companyName) + { + string dotSettingsFilePath = Path.Combine(Settings.WorkingDir, solutionName + ".sln.DotSettings"); + + File.Copy(Path.Combine(Settings.RepoDir, "Solution.sln.DotSettings"), dotSettingsFilePath); + + string contents = File.ReadAllText(dotSettingsFilePath); + + contents = contents.Replace("[CompanyName]", companyName, StringComparison.InvariantCulture); + + File.WriteAllText(dotSettingsFilePath, contents); + } + + public void InitializeReadme(string solutionName, string companyName) + { + string readmeFilePath = Path.Combine(Settings.WorkingDir, "README.md"); + + File.Copy(Path.Combine(Settings.RepoDir, "README.template"), readmeFilePath); + + string contents = File.ReadAllText(readmeFilePath); + + contents = contents.Replace("[SolutionName]", solutionName, StringComparison.InvariantCulture); + + string footerTag = companyName == Settings.DefaultCompany ? Settings.DefaultCompanyTag : companyName; + contents = contents.Replace("[CompanyName]", footerTag, StringComparison.InvariantCulture); + + File.WriteAllText(readmeFilePath, contents); + } + + public void InitializeSolution(string solutionName) + { + string solutionFileName = solutionName + ".sln"; + string solutionFilePath = Path.Combine(Settings.WorkingDir, solutionFileName); + + File.Copy(Path.Combine(Settings.RepoDir, "Solution.sln"), solutionFilePath); + + string contents = File.ReadAllText(solutionFilePath); + + contents = contents.Replace("[Solution.sln.DotSettings]", $"{solutionFileName}.DotSettings", StringComparison.InvariantCulture); + contents = contents.Replace("[SolutionGuid]", Guid.NewGuid().ToString("D"), StringComparison.InvariantCulture); + contents = contents.Replace("[SolutionItemsGuid]", Guid.NewGuid().ToString("D"), StringComparison.InvariantCulture); + + File.WriteAllText(solutionFilePath, contents); + } + + public void InitializeStylecop(string companyName) + { + string stylecopFilePath = Path.Combine(Settings.WorkingDir, "stylecop.json"); + + File.Copy(Path.Combine(Settings.RepoDir, "stylecop.json"), stylecopFilePath); + + string contents = File.ReadAllText(stylecopFilePath); + + contents = contents.Replace("[CompanyName]", companyName, StringComparison.InvariantCulture); + + File.WriteAllText(stylecopFilePath, contents); + } + } +} \ No newline at end of file diff --git a/stylecop.json b/stylecop.json new file mode 100644 index 0000000..2d84453 --- /dev/null +++ b/stylecop.json @@ -0,0 +1,16 @@ +{ + "$schema": "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json", + "settings": { + "indentation": { + "tabSize": 4, + "useTabs": true + }, + "layoutRules": { + "newlineAtEndOfFile": "omit" + }, + "documentationRules": { + "companyName": "Spatial Focus GmbH", + "copyrightText": "Copyright (c) {companyName}. All rights reserved." + } + } +} \ No newline at end of file