[
  {
    "path": ".editorconfig",
    "content": "﻿# Remove the line below if you want to inherit .editorconfig settings from higher directories\nroot = true\n\n# ReSharper annotations\n[Annotations.cs]\ndotnet_diagnostic.CS8618.severity = none\n\n# All files\n[*.*]\n\nmax_line_length=160\n\n# C# files\n[*.cs]\n\n#### Core EditorConfig Options ####\n\n# Indentation and spacing\nindent_size = 4\nindent_style = space\ntab_width = 4\n\n# New line preferences\nend_of_line = crlf\ninsert_final_newline = true\n\n#### .NET Coding Conventions ####\n\n# Organize usings\ndotnet_separate_import_directive_groups = false\ndotnet_sort_system_directives_first = false\nfile_header_template = unset\n\n# this. and Me. preferences\ndotnet_style_qualification_for_event = false:silent\ndotnet_style_qualification_for_field = false:silent\ndotnet_style_qualification_for_method = false:silent\ndotnet_style_qualification_for_property = false:silent\n\n# Language keywords vs BCL types preferences\ndotnet_style_predefined_type_for_locals_parameters_members = true:silent\ndotnet_style_predefined_type_for_member_access = true:silent\n\n# Parentheses preferences\ndotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:silent\ndotnet_style_parentheses_in_other_binary_operators = always_for_clarity:silent\ndotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent\ndotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:silent\n\n# Modifier preferences\ndotnet_style_require_accessibility_modifiers = for_non_interface_members:silent\n\n# Expression-level preferences\ndotnet_style_coalesce_expression = true:suggestion\ndotnet_style_collection_initializer = true:suggestion\ndotnet_style_explicit_tuple_names = true:suggestion\ndotnet_style_null_propagation = true:suggestion\ndotnet_style_object_initializer = true:suggestion\ndotnet_style_operator_placement_when_wrapping = beginning_of_line\ndotnet_style_prefer_auto_properties = true:silent\ndotnet_style_prefer_compound_assignment = true:suggestion\ndotnet_style_prefer_conditional_expression_over_assignment = true:silent\ndotnet_style_prefer_conditional_expression_over_return = true:silent\ndotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion\ndotnet_style_prefer_inferred_tuple_names = true:suggestion\ndotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion\ndotnet_style_prefer_simplified_boolean_expressions = true:suggestion\ndotnet_style_prefer_simplified_interpolation = true:suggestion\n\n# Field preferences\ndotnet_style_readonly_field = true:suggestion\n\n# Parameter preferences\ndotnet_code_quality_unused_parameters = all:suggestion\n\n#### C# Coding Conventions ####\n\n# var preferences\ncsharp_style_var_elsewhere = false:silent\ncsharp_style_var_for_built_in_types = false:silent\ncsharp_style_var_when_type_is_apparent = false:silent\n\n# Expression-bodied members\ncsharp_style_expression_bodied_accessors = true:silent\ncsharp_style_expression_bodied_constructors = false:silent\ncsharp_style_expression_bodied_indexers = true:silent\ncsharp_style_expression_bodied_lambdas = true:silent\ncsharp_style_expression_bodied_local_functions = false:silent\ncsharp_style_expression_bodied_methods = false:silent\ncsharp_style_expression_bodied_operators = false:silent\ncsharp_style_expression_bodied_properties = true:silent\n\n# Pattern matching preferences\ncsharp_style_pattern_matching_over_as_with_null_check = true:suggestion\ncsharp_style_pattern_matching_over_is_with_cast_check = true:suggestion\ncsharp_style_prefer_switch_expression = true:suggestion\n\n# Null-checking preferences\ncsharp_style_conditional_delegate_call = true:suggestion\n\n# Modifier preferences\ncsharp_prefer_static_local_function = true:suggestion\ncsharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:silent\n\n# Code-block preferences\ncsharp_prefer_braces = true:silent\ncsharp_prefer_simple_using_statement = true:suggestion\n\n# Expression-level preferences\ncsharp_prefer_simple_default_expression = true:suggestion\ncsharp_style_deconstructed_variable_declaration = true:suggestion\ncsharp_style_inlined_variable_declaration = true:suggestion\ncsharp_style_pattern_local_over_anonymous_function = true:suggestion\ncsharp_style_prefer_index_operator = true:suggestion\ncsharp_style_prefer_range_operator = true:suggestion\ncsharp_style_throw_expression = true:suggestion\ncsharp_style_unused_value_assignment_preference = discard_variable:suggestion\ncsharp_style_unused_value_expression_statement_preference = discard_variable:silent\n\n# 'using' directive preferences\ncsharp_using_directive_placement = outside_namespace:silent\n\n#### C# Formatting Rules ####\n\n# New line preferences\ncsharp_new_line_before_catch = true\ncsharp_new_line_before_else = true\ncsharp_new_line_before_finally = true\ncsharp_new_line_before_members_in_anonymous_types = true\ncsharp_new_line_before_members_in_object_initializers = true\ncsharp_new_line_before_open_brace = all\ncsharp_new_line_between_query_expression_clauses = true\n\n# Indentation preferences\ncsharp_indent_block_contents = true\ncsharp_indent_braces = false\ncsharp_indent_case_contents = true\ncsharp_indent_case_contents_when_block = true\ncsharp_indent_labels = one_less_than_current\ncsharp_indent_switch_labels = true\n\n# Space preferences\ncsharp_space_after_cast = false\ncsharp_space_after_colon_in_inheritance_clause = true\ncsharp_space_after_comma = true\ncsharp_space_after_dot = false\ncsharp_space_after_keywords_in_control_flow_statements = true\ncsharp_space_after_semicolon_in_for_statement = true\ncsharp_space_around_binary_operators = before_and_after\ncsharp_space_around_declaration_statements = false\ncsharp_space_before_colon_in_inheritance_clause = true\ncsharp_space_before_comma = false\ncsharp_space_before_dot = false\ncsharp_space_before_open_square_brackets = false\ncsharp_space_before_semicolon_in_for_statement = false\ncsharp_space_between_empty_square_brackets = false\ncsharp_space_between_method_call_empty_parameter_list_parentheses = false\ncsharp_space_between_method_call_name_and_opening_parenthesis = false\ncsharp_space_between_method_call_parameter_list_parentheses = false\ncsharp_space_between_method_declaration_empty_parameter_list_parentheses = false\ncsharp_space_between_method_declaration_name_and_open_parenthesis = false\ncsharp_space_between_method_declaration_parameter_list_parentheses = false\ncsharp_space_between_parentheses = false\ncsharp_space_between_square_brackets = false\n\n# Wrapping preferences\ncsharp_preserve_single_line_blocks = true\ncsharp_preserve_single_line_statements = true\n\n#### Naming styles ####\n\n# Naming rules\n\n# Symbol specifications\n\n# Naming styles\n"
  },
  {
    "path": ".github/dependabot.yml",
    "content": "# To get started with Dependabot version updates, you'll need to specify which\n# package ecosystems to update and where the package manifests are located.\n# Please see the documentation for all configuration options:\n# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates\n\nversion: 2\nupdates:\n  - package-ecosystem: \"nuget\"\n    directory: \"/\"\n    schedule:\n      interval: \"daily\"\n    rebase-strategy: \"auto\"\n    reviewers:\n      - \"astenlund\"\n    assignees:\n      - \"astenlund\"\n"
  },
  {
    "path": ".gitignore",
    "content": "﻿## Ignore Visual Studio temporary files, build results, and\n## files generated by popular Visual Studio add-ons.\n##\n## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore\n\n# Image files\n*.png\n\n# Libraries\nlib/*\n\n# Published binaries\npublish/*\n\n# User-specific files\n*.rsuser\n*.suo\n*.user\n*.userosscache\n*.sln.docstates\n\n# User-specific files (MonoDevelop/Xamarin Studio)\n*.userprefs\n\n# Mono auto generated files\nmono_crash.*\n\n# Build results\n[Dd]ebug/\n[Dd]ebugPublic/\n[Rr]elease/\n[Rr]eleases/\nx64/\nx86/\n[Aa][Rr][Mm]/\n[Aa][Rr][Mm]64/\nbld/\n[Bb]in/\n[Oo]bj/\n[Ll]og/\n\n# Visual Studio 2015/2017 cache/options directory\n.vs/\n# Uncomment if you have tasks that create the project's static files in wwwroot\n#wwwroot/\n\n# Visual Studio 2017 auto generated files\nGenerated\\ Files/\n\n# MSTest test Results\n[Tt]est[Rr]esult*/\n[Bb]uild[Ll]og.*\n\n# NUNIT\n*.VisualState.xml\nTestResult.xml\n\n# Build Results of an ATL Project\n[Dd]ebugPS/\n[Rr]eleasePS/\ndlldata.c\n\n# Benchmark Results\nBenchmarkDotNet.Artifacts/\n\n# .NET Core\nproject.lock.json\nproject.fragment.lock.json\nartifacts/\n\n# StyleCop\nStyleCopReport.xml\n\n# Files built by Visual Studio\n*_i.c\n*_p.c\n*_h.h\n*.ilk\n*.meta\n*.obj\n*.iobj\n*.pch\n*.pdb\n*.ipdb\n*.pgc\n*.pgd\n*.rsp\n*.sbr\n*.tlb\n*.tli\n*.tlh\n*.tmp\n*.tmp_proj\n*_wpftmp.csproj\n*.log\n*.vspscc\n*.vssscc\n.builds\n*.pidb\n*.svclog\n*.scc\n\n# Chutzpah Test files\n_Chutzpah*\n\n# Visual C++ cache files\nipch/\n*.aps\n*.ncb\n*.opendb\n*.opensdf\n*.sdf\n*.cachefile\n*.VC.db\n*.VC.VC.opendb\n\n# Visual Studio profiler\n*.psess\n*.vsp\n*.vspx\n*.sap\n\n# Visual Studio Trace Files\n*.e2e\n\n# TFS 2012 Local Workspace\n$tf/\n\n# Guidance Automation Toolkit\n*.gpState\n\n# ReSharper is a .NET coding add-in\n_ReSharper*/\n*.[Rr]e[Ss]harper\n*.DotSettings.user\n\n# JustCode is a .NET coding add-in\n.JustCode\n\n# TeamCity is a build add-in\n_TeamCity*\n\n# DotCover is a Code Coverage Tool\n*.dotCover\n\n# AxoCover is a Code Coverage Tool\n.axoCover/*\n!.axoCover/settings.json\n\n# Visual Studio code coverage results\n*.coverage\n*.coveragexml\n\n# NCrunch\n_NCrunch_*\n.*crunch*.local.xml\nnCrunchTemp_*\n\n# MightyMoose\n*.mm.*\nAutoTest.Net/\n\n# Web workbench (sass)\n.sass-cache/\n\n# Installshield output folder\n[Ee]xpress/\n\n# DocProject is a documentation generator add-in\nDocProject/buildhelp/\nDocProject/Help/*.HxT\nDocProject/Help/*.HxC\nDocProject/Help/*.hhc\nDocProject/Help/*.hhk\nDocProject/Help/*.hhp\nDocProject/Help/Html2\nDocProject/Help/html\n\n# Click-Once directory\npublish/\n\n# Publish Web Output\n*.[Pp]ublish.xml\n*.azurePubxml\n# Note: Comment the next line if you want to checkin your web deploy settings,\n# but database connection strings (with potential passwords) will be unencrypted\n*.pubxml\n*.publishproj\n\n# Microsoft Azure Web App publish settings. Comment the next line if you want to\n# checkin your Azure Web App publish settings, but sensitive information contained\n# in these scripts will be unencrypted\nPublishScripts/\n\n# NuGet Packages\n*.nupkg\n# The packages folder can be ignored because of Package Restore\n**/[Pp]ackages/*\n# except build/, which is used as an MSBuild target.\n!**/[Pp]ackages/build/\n# Uncomment if necessary however generally it will be regenerated when needed\n#!**/[Pp]ackages/repositories.config\n# NuGet v3's project.json files produces more ignorable files\n*.nuget.props\n*.nuget.targets\n\n# Microsoft Azure Build Output\ncsx/\n*.build.csdef\n\n# Microsoft Azure Emulator\necf/\nrcf/\n\n# Windows Store app package directories and files\nAppPackages/\nBundleArtifacts/\nPackage.StoreAssociation.xml\n_pkginfo.txt\n*.appx\n*.appxbundle\n*.appxupload\n\n# Visual Studio cache files\n# files ending in .cache can be ignored\n*.[Cc]ache\n# but keep track of directories ending in .cache\n!?*.[Cc]ache/\n\n# Others\nClientBin/\n~$*\n*~\n*.dbmdl\n*.dbproj.schemaview\n*.jfm\n*.pfx\n*.publishsettings\norleans.codegen.cs\n\n# Including strong name files can present a security risk\n# (https://github.com/github/gitignore/pull/2483#issue-259490424)\n#*.snk\n\n# Since there are multiple workflows, uncomment next line to ignore bower_components\n# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)\n#bower_components/\n\n# RIA/Silverlight projects\nGenerated_Code/\n\n# Backup & report files from converting an old project file\n# to a newer Visual Studio version. Backup files are not needed,\n# because we have git ;-)\n_UpgradeReport_Files/\nBackup*/\nUpgradeLog*.XML\nUpgradeLog*.htm\nServiceFabricBackup/\n*.rptproj.bak\n\n# SQL Server files\n*.mdf\n*.ldf\n*.ndf\n\n# Business Intelligence projects\n*.rdl.data\n*.bim.layout\n*.bim_*.settings\n*.rptproj.rsuser\n*- Backup*.rdl\n\n# Microsoft Fakes\nFakesAssemblies/\n\n# GhostDoc plugin setting file\n*.GhostDoc.xml\n\n# Node.js Tools for Visual Studio\n.ntvs_analysis.dat\nnode_modules/\n\n# Visual Studio 6 build log\n*.plg\n\n# Visual Studio 6 workspace options file\n*.opt\n\n# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)\n*.vbw\n\n# Visual Studio LightSwitch build output\n**/*.HTMLClient/GeneratedArtifacts\n**/*.DesktopClient/GeneratedArtifacts\n**/*.DesktopClient/ModelManifest.xml\n**/*.Server/GeneratedArtifacts\n**/*.Server/ModelManifest.xml\n_Pvt_Extensions\n\n# Paket dependency manager\n.paket/paket.exe\npaket-files/\n\n# FAKE - F# Make\n.fake/\n\n# CodeRush personal settings\n.cr/personal\n\n# Python Tools for Visual Studio (PTVS)\n__pycache__/\n*.pyc\n\n# Cake - Uncomment if you are using it\n# tools/**\n# !tools/packages.config\n\n# Tabs Studio\n*.tss\n\n# Telerik's JustMock configuration file\n*.jmconfig\n\n# BizTalk build output\n*.btp.cs\n*.btm.cs\n*.odx.cs\n*.xsd.cs\n\n# OpenCover UI analysis results\nOpenCover/\n\n# Azure Stream Analytics local run output\nASALocalRun/\n\n# MSBuild Binary and Structured Log\n*.binlog\n\n# NVidia Nsight GPU debugger configuration file\n*.nvuser\n\n# MFractors (Xamarin productivity tool) working folder\n.mfractor/\n\n# Local History for Visual Studio\n.localhistory/\n\n# BeatPulse healthcheck temp database\nhealthchecksdb\n\n# Backup folder for Package Reference Convert tool in Visual Studio 2017\nMigrationBackup/\n\n##\n## Visual studio for Mac\n##\n\n\n# globs\nMakefile.in\n*.userprefs\n*.usertasks\nconfig.make\nconfig.status\naclocal.m4\ninstall-sh\nautom4te.cache/\n*.tar.gz\ntarballs/\ntest-results/\n\n# Mac bundle stuff\n*.dmg\n*.app\n\n# content below from: https://github.com/github/gitignore/blob/master/Global/macOS.gitignore\n# General\n.DS_Store\n.AppleDouble\n.LSOverride\n\n# Icon must end with two \\r\nIcon\n\n\n# Thumbnails\n._*\n\n# Files that might appear in the root of a volume\n.DocumentRevisions-V100\n.fseventsd\n.Spotlight-V100\n.TemporaryItems\n.Trashes\n.VolumeIcon.icns\n.com.apple.timemachine.donotpresent\n\n# Directories potentially created on remote AFP share\n.AppleDB\n.AppleDesktop\nNetwork Trash Folder\nTemporary Items\n.apdisk\n\n# content below from: https://github.com/github/gitignore/blob/master/Global/Windows.gitignore\n# Windows thumbnail cache files\nThumbs.db\nehthumbs.db\nehthumbs_vista.db\n\n# Dump file\n*.stackdump\n\n# Folder config file\n[Dd]esktop.ini\n\n# Recycle Bin used on file shares\n$RECYCLE.BIN/\n\n# Windows Installer files\n*.cab\n*.msi\n*.msix\n*.msm\n*.msp\n\n# Windows shortcuts\n*.lnk\n\n# JetBrains Rider\n.idea/\n*.sln.iml\n\n##\n## Visual Studio Code\n##\n.vscode/*\n!.vscode/settings.json\n!.vscode/tasks.json\n!.vscode/launch.json\n!.vscode/extensions.json\n"
  },
  {
    "path": ".vscode/launch.json",
    "content": "{\n  \"version\": \"0.2.0\",\n  \"configurations\": [\n    {\n      // Use IntelliSense to find out which attributes exist for C# debugging\n      // Use hover for the description of the existing attributes\n      // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md\n      \"name\": \".NET Core Launch (console)\",\n      \"type\": \"coreclr\",\n      \"request\": \"launch\",\n      \"preLaunchTask\": \"build\",\n      // If you have changed target frameworks, make sure to update the program path.\n      \"program\": \"${workspaceFolder}/bin/Debug/netcoreapp3.1/win-x64/fs2ff.exe\",\n      \"args\": [],\n      \"cwd\": \"${workspaceFolder}\",\n      // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console\n      \"console\": \"internalConsole\",\n      \"stopAtEntry\": false\n    },\n    {\n      \"name\": \".NET Core Attach\",\n      \"type\": \"coreclr\",\n      \"request\": \"attach\"\n    }\n  ]\n}"
  },
  {
    "path": ".vscode/tasks.json",
    "content": "{\n  \"version\": \"2.0.0\",\n  \"tasks\": [\n    {\n      \"label\": \"build\",\n      \"command\": \"dotnet\",\n      \"type\": \"process\",\n      \"args\": [\n        \"build\",\n        \"${workspaceFolder}/fs2ff.csproj\",\n        \"/property:GenerateFullPaths=true\",\n        \"/consoleloggerparameters:NoSummary\"\n      ],\n      \"problemMatcher\": \"$msCompile\"\n    },\n    {\n      \"label\": \"publish\",\n      \"command\": \"dotnet\",\n      \"type\": \"process\",\n      \"args\": [\n        \"publish\",\n        \"${workspaceFolder}/fs2ff.csproj\",\n        \"/property:GenerateFullPaths=true\",\n        \"/consoleloggerparameters:NoSummary\"\n      ],\n      \"problemMatcher\": \"$msCompile\"\n    },\n    {\n      \"label\": \"watch\",\n      \"command\": \"dotnet\",\n      \"type\": \"process\",\n      \"args\": [\n        \"watch\",\n        \"run\",\n        \"${workspaceFolder}/fs2ff.csproj\",\n        \"/property:GenerateFullPaths=true\",\n        \"/consoleloggerparameters:NoSummary\"\n      ],\n      \"problemMatcher\": \"$msCompile\"\n    }\n  ]\n}"
  },
  {
    "path": "ActionCommand.cs",
    "content": "﻿// ReSharper disable UnusedMember.Global\n// ReSharper disable UnusedType.Global\n\nusing System;\nusing System.Windows.Input;\n\nnamespace fs2ff\n{\n    public class ActionCommand : ICommand\n    {\n        private readonly Action _action;\n        private readonly Func<bool> _predicate;\n\n        public ActionCommand()\n        {\n            _action = () => { };\n            _predicate = () => true;\n        }\n\n        public ActionCommand(Action action)\n        {\n            _action = action;\n            _predicate = () => true;\n        }\n\n        public ActionCommand(Action action, Func<bool> predicate)\n        {\n            _action = action;\n            _predicate = predicate;\n        }\n\n        public event EventHandler? CanExecuteChanged;\n\n        public bool CanExecute(object? _) => _predicate();\n\n        public void Execute(object? parameter) => _action();\n\n        public void TriggerCanExecuteChanged() => CanExecuteChanged?.Invoke(this, new EventArgs());\n    }\n\n    public class ActionCommand<T> : ICommand where T : struct\n    {\n        private readonly Action<T?> _action;\n        private readonly Func<T?, bool> _predicate;\n\n        public ActionCommand()\n        {\n            _action = _ => { };\n            _predicate = _ => true;\n        }\n\n        public ActionCommand(Action<T?> action)\n        {\n            _action = action;\n            _predicate = _ => true;\n        }\n\n        public ActionCommand(Action<T?> action, Func<T?, bool> predicate)\n        {\n            _action = action;\n            _predicate = predicate;\n        }\n\n        public event EventHandler? CanExecuteChanged;\n\n        public bool CanExecute(object? parameter) => parameter is T param ? _predicate(param) : _predicate(null);\n\n        public void Execute(object? parameter)\n        {\n            if (parameter is T param) _action(param);\n            else                      _action(null);\n        }\n\n        public void TriggerCanExecuteChanged() => CanExecuteChanged?.Invoke(this, new EventArgs());\n    }\n}\n"
  },
  {
    "path": "Annotations.cs",
    "content": "﻿/* MIT License\n\nCopyright (c) 2016 JetBrains http://www.jetbrains.com\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE. */\n\nusing System;\n// ReSharper disable InheritdocConsiderUsage\n\n#pragma warning disable 1591\n// ReSharper disable UnusedMember.Global\n// ReSharper disable MemberCanBePrivate.Global\n// ReSharper disable UnusedAutoPropertyAccessor.Global\n// ReSharper disable IntroduceOptionalParameters.Global\n// ReSharper disable MemberCanBeProtected.Global\n// ReSharper disable InconsistentNaming\n\nnamespace fs2ff.Annotations\n{\n  /// <summary>\n  /// Indicates that the value of the marked element could be <c>null</c> sometimes,\n  /// so checking for <c>null</c> is required before its usage.\n  /// </summary>\n  /// <example><code>\n  /// [CanBeNull] object Test() => null;\n  /// \n  /// void UseTest() {\n  ///   var p = Test();\n  ///   var s = p.ToString(); // Warning: Possible 'System.NullReferenceException'\n  /// }\n  /// </code></example>\n  [AttributeUsage(\n    AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property |\n    AttributeTargets.Delegate | AttributeTargets.Field | AttributeTargets.Event |\n    AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.GenericParameter)]\n  public sealed class CanBeNullAttribute : Attribute { }\n\n  /// <summary>\n  /// Indicates that the value of the marked element can never be <c>null</c>.\n  /// </summary>\n  /// <example><code>\n  /// [NotNull] object Foo() {\n  ///   return null; // Warning: Possible 'null' assignment\n  /// }\n  /// </code></example>\n  [AttributeUsage(\n    AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property |\n    AttributeTargets.Delegate | AttributeTargets.Field | AttributeTargets.Event |\n    AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.GenericParameter)]\n  public sealed class NotNullAttribute : Attribute { }\n\n  /// <summary>\n  /// Can be applied to symbols of types derived from IEnumerable as well as to symbols of Task\n  /// and Lazy classes to indicate that the value of a collection item, of the Task.Result property\n  /// or of the Lazy.Value property can never be null.\n  /// </summary>\n  /// <example><code>\n  /// public void Foo([ItemNotNull]List&lt;string&gt; books)\n  /// {\n  ///   foreach (var book in books) {\n  ///     if (book != null) // Warning: Expression is always true\n  ///      Console.WriteLine(book.ToUpper());\n  ///   }\n  /// }\n  /// </code></example>\n  [AttributeUsage(\n    AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property |\n    AttributeTargets.Delegate | AttributeTargets.Field)]\n  public sealed class ItemNotNullAttribute : Attribute { }\n\n  /// <summary>\n  /// Can be applied to symbols of types derived from IEnumerable as well as to symbols of Task\n  /// and Lazy classes to indicate that the value of a collection item, of the Task.Result property\n  /// or of the Lazy.Value property can be null.\n  /// </summary>\n  /// <example><code>\n  /// public void Foo([ItemCanBeNull]List&lt;string&gt; books)\n  /// {\n  ///   foreach (var book in books)\n  ///   {\n  ///     // Warning: Possible 'System.NullReferenceException'\n  ///     Console.WriteLine(book.ToUpper());\n  ///   }\n  /// }\n  /// </code></example>\n  [AttributeUsage(\n    AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property |\n    AttributeTargets.Delegate | AttributeTargets.Field)]\n  public sealed class ItemCanBeNullAttribute : Attribute { }\n\n  /// <summary>\n  /// Indicates that the marked method builds string by the format pattern and (optional) arguments.\n  /// The parameter, which contains the format string, should be given in constructor. The format string\n  /// should be in <see cref=\"string.Format(IFormatProvider,string,object[])\"/>-like form.\n  /// </summary>\n  /// <example><code>\n  /// [StringFormatMethod(\"message\")]\n  /// void ShowError(string message, params object[] args) { /* do something */ }\n  /// \n  /// void Foo() {\n  ///   ShowError(\"Failed: {0}\"); // Warning: Non-existing argument in format string\n  /// }\n  /// </code></example>\n  [AttributeUsage(\n    AttributeTargets.Constructor | AttributeTargets.Method |\n    AttributeTargets.Property | AttributeTargets.Delegate)]\n  public sealed class StringFormatMethodAttribute : Attribute\n  {\n    /// <param name=\"formatParameterName\">\n    /// Specifies which parameter of an annotated method should be treated as the format string\n    /// </param>\n    public StringFormatMethodAttribute([NotNull] string formatParameterName)\n    {\n      FormatParameterName = formatParameterName;\n    }\n\n    [NotNull] public string FormatParameterName { get; }\n  }\n\n  /// <summary>\n  /// Use this annotation to specify a type that contains static or const fields\n  /// with values for the annotated property/field/parameter.\n  /// The specified type will be used to improve completion suggestions.\n  /// </summary>\n  /// <example><code>\n  /// namespace TestNamespace\n  /// {\n  ///   public class Constants\n  ///   {\n  ///     public static int INT_CONST = 1;\n  ///     public const string STRING_CONST = \"1\";\n  ///   }\n  ///\n  ///   public class Class1\n  ///   {\n  ///     [ValueProvider(\"TestNamespace.Constants\")] public int myField;\n  ///     public void Foo([ValueProvider(\"TestNamespace.Constants\")] string str) { }\n  ///\n  ///     public void Test()\n  ///     {\n  ///       Foo(/*try completion here*/);//\n  ///       myField = /*try completion here*/\n  ///     }\n  ///   }\n  /// }\n  /// </code></example>\n  [AttributeUsage(\n    AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.Field,\n    AllowMultiple = true)]\n  public sealed class ValueProviderAttribute : Attribute\n  {\n    public ValueProviderAttribute([NotNull] string name)\n    {\n      Name = name;\n    }\n\n    [NotNull] public string Name { get; }\n  }\n\n  /// <summary>\n  /// Indicates that the integral value falls into the specified interval.\n  /// It's allowed to specify multiple non-intersecting intervals.\n  /// Values of interval boundaries are inclusive.\n  /// </summary>\n  /// <example><code>\n  /// void Foo([ValueRange(0, 100)] int value) {\n  ///   if (value == -1) { // Warning: Expression is always 'false'\n  ///     ...\n  ///   }\n  /// }\n  /// </code></example>\n  [AttributeUsage(\n    AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property |\n    AttributeTargets.Method | AttributeTargets.Delegate,\n    AllowMultiple = true)]\n  public sealed class ValueRangeAttribute : Attribute\n  {\n    public object From { get; }\n    public object To { get; }\n\n    public ValueRangeAttribute(long from, long to)\n    {\n      From = from;\n      To = to;\n    }\n\n    public ValueRangeAttribute(ulong from, ulong to)\n    {\n      From = from;\n      To = to;\n    }\n\n    public ValueRangeAttribute(long value)\n    {\n      From = To = value;\n    }\n\n    public ValueRangeAttribute(ulong value)\n    {\n      From = To = value;\n    }\n  }\n\n  /// <summary>\n  /// Indicates that the integral value never falls below zero.\n  /// </summary>\n  /// <example><code>\n  /// void Foo([NonNegativeValue] int value) {\n  ///   if (value == -1) { // Warning: Expression is always 'false'\n  ///     ...\n  ///   }\n  /// }\n  /// </code></example>\n  [AttributeUsage(\n    AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property |\n    AttributeTargets.Method | AttributeTargets.Delegate)]\n  public sealed class NonNegativeValueAttribute : Attribute { }\n\n  /// <summary>\n  /// Indicates that the function argument should be a string literal and match one\n  /// of the parameters of the caller function. For example, ReSharper annotates\n  /// the parameter of <see cref=\"System.ArgumentNullException\"/>.\n  /// </summary>\n  /// <example><code>\n  /// void Foo(string param) {\n  ///   if (param == null)\n  ///     throw new ArgumentNullException(\"par\"); // Warning: Cannot resolve symbol\n  /// }\n  /// </code></example>\n  [AttributeUsage(AttributeTargets.Parameter)]\n  public sealed class InvokerParameterNameAttribute : Attribute { }\n\n  /// <summary>\n  /// Indicates that the method is contained in a type that implements\n  /// <c>System.ComponentModel.INotifyPropertyChanged</c> interface and this method\n  /// is used to notify that some property value changed.\n  /// </summary>\n  /// <remarks>\n  /// The method should be non-static and conform to one of the supported signatures:\n  /// <list>\n  /// <item><c>NotifyChanged(string)</c></item>\n  /// <item><c>NotifyChanged(params string[])</c></item>\n  /// <item><c>NotifyChanged{T}(Expression{Func{T}})</c></item>\n  /// <item><c>NotifyChanged{T,U}(Expression{Func{T,U}})</c></item>\n  /// <item><c>SetProperty{T}(ref T, T, string)</c></item>\n  /// </list>\n  /// </remarks>\n  /// <example><code>\n  /// public class Foo : INotifyPropertyChanged {\n  ///   public event PropertyChangedEventHandler PropertyChanged;\n  /// \n  ///   [NotifyPropertyChangedInvocator]\n  ///   protected virtual void NotifyChanged(string propertyName) { ... }\n  ///\n  ///   string _name;\n  /// \n  ///   public string Name {\n  ///     get { return _name; }\n  ///     set { _name = value; NotifyChanged(\"LastName\"); /* Warning */ }\n  ///   }\n  /// }\n  /// </code>\n  /// Examples of generated notifications:\n  /// <list>\n  /// <item><c>NotifyChanged(\"Property\")</c></item>\n  /// <item><c>NotifyChanged(() =&gt; Property)</c></item>\n  /// <item><c>NotifyChanged((VM x) =&gt; x.Property)</c></item>\n  /// <item><c>SetProperty(ref myField, value, \"Property\")</c></item>\n  /// </list>\n  /// </example>\n  [AttributeUsage(AttributeTargets.Method)]\n  public sealed class NotifyPropertyChangedInvocatorAttribute : Attribute\n  {\n    public NotifyPropertyChangedInvocatorAttribute() { }\n    public NotifyPropertyChangedInvocatorAttribute([NotNull] string parameterName)\n    {\n      ParameterName = parameterName;\n    }\n\n    [CanBeNull] public string ParameterName { get; }\n  }\n\n  /// <summary>\n  /// Describes dependency between method input and output.\n  /// </summary>\n  /// <syntax>\n  /// <p>Function Definition Table syntax:</p>\n  /// <list>\n  /// <item>FDT      ::= FDTRow [;FDTRow]*</item>\n  /// <item>FDTRow   ::= Input =&gt; Output | Output &lt;= Input</item>\n  /// <item>Input    ::= ParameterName: Value [, Input]*</item>\n  /// <item>Output   ::= [ParameterName: Value]* {halt|stop|void|nothing|Value}</item>\n  /// <item>Value    ::= true | false | null | notnull | canbenull</item>\n  /// </list>\n  /// If the method has a single input parameter, its name could be omitted.<br/>\n  /// Using <c>halt</c> (or <c>void</c>/<c>nothing</c>, which is the same) for the method output\n  /// means that the method doesn't return normally (throws or terminates the process).<br/>\n  /// Value <c>canbenull</c> is only applicable for output parameters.<br/>\n  /// You can use multiple <c>[ContractAnnotation]</c> for each FDT row, or use single attribute\n  /// with rows separated by semicolon. There is no notion of order rows, all rows are checked\n  /// for applicability and applied per each program state tracked by the analysis engine.<br/>\n  /// </syntax>\n  /// <examples><list>\n  /// <item><code>\n  /// [ContractAnnotation(\"=&gt; halt\")]\n  /// public void TerminationMethod()\n  /// </code></item>\n  /// <item><code>\n  /// [ContractAnnotation(\"null &lt;= param:null\")] // reverse condition syntax\n  /// public string GetName(string surname)\n  /// </code></item>\n  /// <item><code>\n  /// [ContractAnnotation(\"s:null =&gt; true\")]\n  /// public bool IsNullOrEmpty(string s) // string.IsNullOrEmpty()\n  /// </code></item>\n  /// <item><code>\n  /// // A method that returns null if the parameter is null,\n  /// // and not null if the parameter is not null\n  /// [ContractAnnotation(\"null =&gt; null; notnull =&gt; notnull\")]\n  /// public object Transform(object data)\n  /// </code></item>\n  /// <item><code>\n  /// [ContractAnnotation(\"=&gt; true, result: notnull; =&gt; false, result: null\")]\n  /// public bool TryParse(string s, out Person result)\n  /// </code></item>\n  /// </list></examples>\n  [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]\n  public sealed class ContractAnnotationAttribute : Attribute\n  {\n    public ContractAnnotationAttribute([NotNull] string contract)\n      : this(contract, false) { }\n\n    public ContractAnnotationAttribute([NotNull] string contract, bool forceFullStates)\n    {\n      Contract = contract;\n      ForceFullStates = forceFullStates;\n    }\n\n    [NotNull] public string Contract { get; }\n\n    public bool ForceFullStates { get; }\n  }\n\n  /// <summary>\n  /// Indicates whether the marked element should be localized.\n  /// </summary>\n  /// <example><code>\n  /// [LocalizationRequiredAttribute(true)]\n  /// class Foo {\n  ///   string str = \"my string\"; // Warning: Localizable string\n  /// }\n  /// </code></example>\n  [AttributeUsage(AttributeTargets.All)]\n  public sealed class LocalizationRequiredAttribute : Attribute\n  {\n    public LocalizationRequiredAttribute() : this(true) { }\n\n    public LocalizationRequiredAttribute(bool required)\n    {\n      Required = required;\n    }\n\n    public bool Required { get; }\n  }\n\n  /// <summary>\n  /// Indicates that the value of the marked type (or its derivatives)\n  /// cannot be compared using '==' or '!=' operators and <c>Equals()</c>\n  /// should be used instead. However, using '==' or '!=' for comparison\n  /// with <c>null</c> is always permitted.\n  /// </summary>\n  /// <example><code>\n  /// [CannotApplyEqualityOperator]\n  /// class NoEquality { }\n  /// \n  /// class UsesNoEquality {\n  ///   void Test() {\n  ///     var ca1 = new NoEquality();\n  ///     var ca2 = new NoEquality();\n  ///     if (ca1 != null) { // OK\n  ///       bool condition = ca1 == ca2; // Warning\n  ///     }\n  ///   }\n  /// }\n  /// </code></example>\n  [AttributeUsage(AttributeTargets.Interface | AttributeTargets.Class | AttributeTargets.Struct)]\n  public sealed class CannotApplyEqualityOperatorAttribute : Attribute { }\n\n  /// <summary>\n  /// When applied to a target attribute, specifies a requirement for any type marked\n  /// with the target attribute to implement or inherit specific type or types.\n  /// </summary>\n  /// <example><code>\n  /// [BaseTypeRequired(typeof(IComponent)] // Specify requirement\n  /// class ComponentAttribute : Attribute { }\n  /// \n  /// [Component] // ComponentAttribute requires implementing IComponent interface\n  /// class MyComponent : IComponent { }\n  /// </code></example>\n  [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]\n  [BaseTypeRequired(typeof(Attribute))]\n  public sealed class BaseTypeRequiredAttribute : Attribute\n  {\n    public BaseTypeRequiredAttribute([NotNull] Type baseType)\n    {\n      BaseType = baseType;\n    }\n\n    [NotNull] public Type BaseType { get; }\n  }\n\n  /// <summary>\n  /// Indicates that the marked symbol is used implicitly (e.g. via reflection, in external library),\n  /// so this symbol will not be reported as unused (as well as by other usage inspections).\n  /// </summary>\n  [AttributeUsage(AttributeTargets.All)]\n  public sealed class UsedImplicitlyAttribute : Attribute\n  {\n    public UsedImplicitlyAttribute()\n      : this(ImplicitUseKindFlags.Default, ImplicitUseTargetFlags.Default) { }\n\n    public UsedImplicitlyAttribute(ImplicitUseKindFlags useKindFlags)\n      : this(useKindFlags, ImplicitUseTargetFlags.Default) { }\n\n    public UsedImplicitlyAttribute(ImplicitUseTargetFlags targetFlags)\n      : this(ImplicitUseKindFlags.Default, targetFlags) { }\n\n    public UsedImplicitlyAttribute(ImplicitUseKindFlags useKindFlags, ImplicitUseTargetFlags targetFlags)\n    {\n      UseKindFlags = useKindFlags;\n      TargetFlags = targetFlags;\n    }\n\n    public ImplicitUseKindFlags UseKindFlags { get; }\n\n    public ImplicitUseTargetFlags TargetFlags { get; }\n  }\n\n  /// <summary>\n  /// Can be applied to attributes, type parameters, and parameters of a type assignable from <see cref=\"System.Type\"/> .\n  /// When applied to an attribute, the decorated attribute behaves the same as <see cref=\"UsedImplicitlyAttribute\"/>.\n  /// When applied to a type parameter or to a parameter of type <see cref=\"System.Type\"/>,  indicates that the corresponding type\n  /// is used implicitly.\n  /// </summary>\n  [AttributeUsage(AttributeTargets.Class | AttributeTargets.GenericParameter | AttributeTargets.Parameter)]\n  public sealed class MeansImplicitUseAttribute : Attribute\n  {\n    public MeansImplicitUseAttribute()\n      : this(ImplicitUseKindFlags.Default, ImplicitUseTargetFlags.Default) { }\n\n    public MeansImplicitUseAttribute(ImplicitUseKindFlags useKindFlags)\n      : this(useKindFlags, ImplicitUseTargetFlags.Default) { }\n\n    public MeansImplicitUseAttribute(ImplicitUseTargetFlags targetFlags)\n      : this(ImplicitUseKindFlags.Default, targetFlags) { }\n\n    public MeansImplicitUseAttribute(ImplicitUseKindFlags useKindFlags, ImplicitUseTargetFlags targetFlags)\n    {\n      UseKindFlags = useKindFlags;\n      TargetFlags = targetFlags;\n    }\n\n    [UsedImplicitly] public ImplicitUseKindFlags UseKindFlags { get; }\n\n    [UsedImplicitly] public ImplicitUseTargetFlags TargetFlags { get; }\n  }\n\n  /// <summary>\n  /// Specify the details of implicitly used symbol when it is marked\n  /// with <see cref=\"MeansImplicitUseAttribute\"/> or <see cref=\"UsedImplicitlyAttribute\"/>.\n  /// </summary>\n  [Flags]\n  public enum ImplicitUseKindFlags\n  {\n    Default = Access | Assign | InstantiatedWithFixedConstructorSignature,\n    /// <summary>Only entity marked with attribute considered used.</summary>\n    Access = 1,\n    /// <summary>Indicates implicit assignment to a member.</summary>\n    Assign = 2,\n    /// <summary>\n    /// Indicates implicit instantiation of a type with fixed constructor signature.\n    /// That means any unused constructor parameters won't be reported as such.\n    /// </summary>\n    InstantiatedWithFixedConstructorSignature = 4,\n    /// <summary>Indicates implicit instantiation of a type.</summary>\n    InstantiatedNoFixedConstructorSignature = 8,\n  }\n\n  /// <summary>\n  /// Specify what is considered to be used implicitly when marked\n  /// with <see cref=\"MeansImplicitUseAttribute\"/> or <see cref=\"UsedImplicitlyAttribute\"/>.\n  /// </summary>\n  [Flags]\n  public enum ImplicitUseTargetFlags\n  {\n    Default = Itself,\n    Itself = 1,\n    /// <summary>Members of entity marked with attribute are considered used.</summary>\n    Members = 2,\n    /// <summary> Inherited entities are considered used. </summary>\n    WithInheritors = 4,\n    /// <summary>Entity marked with attribute and all its members considered used.</summary>\n    WithMembers = Itself | Members\n  }\n\n  /// <summary>\n  /// This attribute is intended to mark publicly available API\n  /// which should not be removed and so is treated as used.\n  /// </summary>\n  [MeansImplicitUse(ImplicitUseTargetFlags.WithMembers)]\n  [AttributeUsage(AttributeTargets.All, Inherited = false)]\n  public sealed class PublicAPIAttribute : Attribute\n  {\n    public PublicAPIAttribute() { }\n\n    public PublicAPIAttribute([NotNull] string comment)\n    {\n      Comment = comment;\n    }\n\n    [CanBeNull] public string Comment { get; }\n  }\n\n  /// <summary>\n  /// Tells code analysis engine if the parameter is completely handled when the invoked method is on stack.\n  /// If the parameter is a delegate, indicates that delegate is executed while the method is executed.\n  /// If the parameter is an enumerable, indicates that it is enumerated while the method is executed.\n  /// </summary>\n  [AttributeUsage(AttributeTargets.Parameter)]\n  public sealed class InstantHandleAttribute : Attribute { }\n\n  /// <summary>\n  /// Indicates that a method does not make any observable state changes.\n  /// The same as <c>System.Diagnostics.Contracts.PureAttribute</c>.\n  /// </summary>\n  /// <example><code>\n  /// [Pure] int Multiply(int x, int y) => x * y;\n  /// \n  /// void M() {\n  ///   Multiply(123, 42); // Warning: Return value of pure method is not used\n  /// }\n  /// </code></example>\n  [AttributeUsage(AttributeTargets.Method)]\n  public sealed class PureAttribute : Attribute { }\n\n  /// <summary>\n  /// Indicates that the return value of the method invocation must be used.\n  /// </summary>\n  /// <remarks>\n  /// Methods decorated with this attribute (in contrast to pure methods) might change state,\n  /// but make no sense without using their return value. <br/>\n  /// Similarly to <see cref=\"PureAttribute\"/>, this attribute\n  /// will help detecting usages of the method when the return value in not used.\n  /// Additionally, you can optionally specify a custom message, which will be used when showing warnings, e.g.\n  /// <code>[MustUseReturnValue(\"Use the return value to...\")]</code>.\n  /// </remarks>\n  [AttributeUsage(AttributeTargets.Method)]\n  public sealed class MustUseReturnValueAttribute : Attribute\n  {\n    public MustUseReturnValueAttribute() { }\n\n    public MustUseReturnValueAttribute([NotNull] string justification)\n    {\n      Justification = justification;\n    }\n\n    [CanBeNull] public string Justification { get; }\n  }\n\n  /// <summary>\n  /// Indicates the type member or parameter of some type, that should be used instead of all other ways\n  /// to get the value of that type. This annotation is useful when you have some \"context\" value evaluated\n  /// and stored somewhere, meaning that all other ways to get this value must be consolidated with existing one.\n  /// </summary>\n  /// <example><code>\n  /// class Foo {\n  ///   [ProvidesContext] IBarService _barService = ...;\n  /// \n  ///   void ProcessNode(INode node) {\n  ///     DoSomething(node, node.GetGlobalServices().Bar);\n  ///     //              ^ Warning: use value of '_barService' field\n  ///   }\n  /// }\n  /// </code></example>\n  [AttributeUsage(\n    AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Parameter | AttributeTargets.Method |\n    AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.Struct | AttributeTargets.GenericParameter)]\n  public sealed class ProvidesContextAttribute : Attribute { }\n\n  /// <summary>\n  /// Indicates that a parameter is a path to a file or a folder within a web project.\n  /// Path can be relative or absolute, starting from web root (~).\n  /// </summary>\n  [AttributeUsage(AttributeTargets.Parameter)]\n  public sealed class PathReferenceAttribute : Attribute\n  {\n    public PathReferenceAttribute() { }\n\n    public PathReferenceAttribute([NotNull, PathReference] string basePath)\n    {\n      BasePath = basePath;\n    }\n\n    [CanBeNull] public string BasePath { get; }\n  }\n\n  /// <summary>\n  /// An extension method marked with this attribute is processed by code completion\n  /// as a 'Source Template'. When the extension method is completed over some expression, its source code\n  /// is automatically expanded like a template at call site.\n  /// </summary>\n  /// <remarks>\n  /// Template method body can contain valid source code and/or special comments starting with '$'.\n  /// Text inside these comments is added as source code when the template is applied. Template parameters\n  /// can be used either as additional method parameters or as identifiers wrapped in two '$' signs.\n  /// Use the <see cref=\"MacroAttribute\"/> attribute to specify macros for parameters.\n  /// </remarks>\n  /// <example>\n  /// In this example, the 'forEach' method is a source template available over all values\n  /// of enumerable types, producing ordinary C# 'foreach' statement and placing caret inside block:\n  /// <code>\n  /// [SourceTemplate]\n  /// public static void forEach&lt;T&gt;(this IEnumerable&lt;T&gt; xs) {\n  ///   foreach (var x in xs) {\n  ///      //$ $END$\n  ///   }\n  /// }\n  /// </code>\n  /// </example>\n  [AttributeUsage(AttributeTargets.Method)]\n  public sealed class SourceTemplateAttribute : Attribute { }\n\n  /// <summary>\n  /// Allows specifying a macro for a parameter of a <see cref=\"SourceTemplateAttribute\">source template</see>.\n  /// </summary>\n  /// <remarks>\n  /// You can apply the attribute on the whole method or on any of its additional parameters. The macro expression\n  /// is defined in the <see cref=\"MacroAttribute.Expression\"/> property. When applied on a method, the target\n  /// template parameter is defined in the <see cref=\"MacroAttribute.Target\"/> property. To apply the macro silently\n  /// for the parameter, set the <see cref=\"MacroAttribute.Editable\"/> property value = -1.\n  /// </remarks>\n  /// <example>\n  /// Applying the attribute on a source template method:\n  /// <code>\n  /// [SourceTemplate, Macro(Target = \"item\", Expression = \"suggestVariableName()\")]\n  /// public static void forEach&lt;T&gt;(this IEnumerable&lt;T&gt; collection) {\n  ///   foreach (var item in collection) {\n  ///     //$ $END$\n  ///   }\n  /// }\n  /// </code>\n  /// Applying the attribute on a template method parameter:\n  /// <code>\n  /// [SourceTemplate]\n  /// public static void something(this Entity x, [Macro(Expression = \"guid()\", Editable = -1)] string newguid) {\n  ///   /*$ var $x$Id = \"$newguid$\" + x.ToString();\n  ///   x.DoSomething($x$Id); */\n  /// }\n  /// </code>\n  /// </example>\n  [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method, AllowMultiple = true)]\n  public sealed class MacroAttribute : Attribute\n  {\n    /// <summary>\n    /// Allows specifying a macro that will be executed for a <see cref=\"SourceTemplateAttribute\">source template</see>\n    /// parameter when the template is expanded.\n    /// </summary>\n    [CanBeNull] public string Expression { get; set; }\n\n    /// <summary>\n    /// Allows specifying which occurrence of the target parameter becomes editable when the template is deployed.\n    /// </summary>\n    /// <remarks>\n    /// If the target parameter is used several times in the template, only one occurrence becomes editable;\n    /// other occurrences are changed synchronously. To specify the zero-based index of the editable occurrence,\n    /// use values >= 0. To make the parameter non-editable when the template is expanded, use -1.\n    /// </remarks>\n    public int Editable { get; set; }\n\n    /// <summary>\n    /// Identifies the target parameter of a <see cref=\"SourceTemplateAttribute\">source template</see> if the\n    /// <see cref=\"MacroAttribute\"/> is applied on a template method.\n    /// </summary>\n    [CanBeNull] public string Target { get; set; }\n  }\n\n  [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = true)]\n  public sealed class AspMvcAreaMasterLocationFormatAttribute : Attribute\n  {\n    public AspMvcAreaMasterLocationFormatAttribute([NotNull] string format)\n    {\n      Format = format;\n    }\n\n    [NotNull] public string Format { get; }\n  }\n\n  [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = true)]\n  public sealed class AspMvcAreaPartialViewLocationFormatAttribute : Attribute\n  {\n    public AspMvcAreaPartialViewLocationFormatAttribute([NotNull] string format)\n    {\n      Format = format;\n    }\n\n    [NotNull] public string Format { get; }\n  }\n\n  [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = true)]\n  public sealed class AspMvcAreaViewLocationFormatAttribute : Attribute\n  {\n    public AspMvcAreaViewLocationFormatAttribute([NotNull] string format)\n    {\n      Format = format;\n    }\n\n    [NotNull] public string Format { get; }\n  }\n\n  [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = true)]\n  public sealed class AspMvcMasterLocationFormatAttribute : Attribute\n  {\n    public AspMvcMasterLocationFormatAttribute([NotNull] string format)\n    {\n      Format = format;\n    }\n\n    [NotNull] public string Format { get; }\n  }\n\n  [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = true)]\n  public sealed class AspMvcPartialViewLocationFormatAttribute : Attribute\n  {\n    public AspMvcPartialViewLocationFormatAttribute([NotNull] string format)\n    {\n      Format = format;\n    }\n\n    [NotNull] public string Format { get; }\n  }\n\n  [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = true)]\n  public sealed class AspMvcViewLocationFormatAttribute : Attribute\n  {\n    public AspMvcViewLocationFormatAttribute([NotNull] string format)\n    {\n      Format = format;\n    }\n\n    [NotNull] public string Format { get; }\n  }\n\n  /// <summary>\n  /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter\n  /// is an MVC action. If applied to a method, the MVC action name is calculated\n  /// implicitly from the context. Use this attribute for custom wrappers similar to\n  /// <c>System.Web.Mvc.Html.ChildActionExtensions.RenderAction(HtmlHelper, String)</c>.\n  /// </summary>\n  [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method | AttributeTargets.Field | AttributeTargets.Property)]\n  public sealed class AspMvcActionAttribute : Attribute\n  {\n    public AspMvcActionAttribute() { }\n\n    public AspMvcActionAttribute([NotNull] string anonymousProperty)\n    {\n      AnonymousProperty = anonymousProperty;\n    }\n\n    [CanBeNull] public string AnonymousProperty { get; }\n  }\n\n  /// <summary>\n  /// ASP.NET MVC attribute. Indicates that the marked parameter is an MVC area.\n  /// Use this attribute for custom wrappers similar to\n  /// <c>System.Web.Mvc.Html.ChildActionExtensions.RenderAction(HtmlHelper, String)</c>.\n  /// </summary>\n  [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property)]\n  public sealed class AspMvcAreaAttribute : Attribute\n  {\n    public AspMvcAreaAttribute() { }\n\n    public AspMvcAreaAttribute([NotNull] string anonymousProperty)\n    {\n      AnonymousProperty = anonymousProperty;\n    }\n\n    [CanBeNull] public string AnonymousProperty { get; }\n  }\n\n  /// <summary>\n  /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter is\n  /// an MVC controller. If applied to a method, the MVC controller name is calculated\n  /// implicitly from the context. Use this attribute for custom wrappers similar to\n  /// <c>System.Web.Mvc.Html.ChildActionExtensions.RenderAction(HtmlHelper, String, String)</c>.\n  /// </summary>\n  [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method | AttributeTargets.Field | AttributeTargets.Property)]\n  public sealed class AspMvcControllerAttribute : Attribute\n  {\n    public AspMvcControllerAttribute() { }\n\n    public AspMvcControllerAttribute([NotNull] string anonymousProperty)\n    {\n      AnonymousProperty = anonymousProperty;\n    }\n\n    [CanBeNull] public string AnonymousProperty { get; }\n  }\n\n  /// <summary>\n  /// ASP.NET MVC attribute. Indicates that the marked parameter is an MVC Master. Use this attribute\n  /// for custom wrappers similar to <c>System.Web.Mvc.Controller.View(String, String)</c>.\n  /// </summary>\n  [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property)]\n  public sealed class AspMvcMasterAttribute : Attribute { }\n\n  /// <summary>\n  /// ASP.NET MVC attribute. Indicates that the marked parameter is an MVC model type. Use this attribute\n  /// for custom wrappers similar to <c>System.Web.Mvc.Controller.View(String, Object)</c>.\n  /// </summary>\n  [AttributeUsage(AttributeTargets.Parameter)]\n  public sealed class AspMvcModelTypeAttribute : Attribute { }\n\n  /// <summary>\n  /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter is an MVC\n  /// partial view. If applied to a method, the MVC partial view name is calculated implicitly\n  /// from the context. Use this attribute for custom wrappers similar to\n  /// <c>System.Web.Mvc.Html.RenderPartialExtensions.RenderPartial(HtmlHelper, String)</c>.\n  /// </summary>\n  [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method | AttributeTargets.Field | AttributeTargets.Property)]\n  public sealed class AspMvcPartialViewAttribute : Attribute { }\n\n  /// <summary>\n  /// ASP.NET MVC attribute. Allows disabling inspections for MVC views within a class or a method.\n  /// </summary>\n  [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)]\n  public sealed class AspMvcSuppressViewErrorAttribute : Attribute { }\n\n  /// <summary>\n  /// ASP.NET MVC attribute. Indicates that a parameter is an MVC display template.\n  /// Use this attribute for custom wrappers similar to\n  /// <c>System.Web.Mvc.Html.DisplayExtensions.DisplayForModel(HtmlHelper, String)</c>.\n  /// </summary>\n  [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property)]\n  public sealed class AspMvcDisplayTemplateAttribute : Attribute { }\n\n  /// <summary>\n  /// ASP.NET MVC attribute. Indicates that the marked parameter is an MVC editor template.\n  /// Use this attribute for custom wrappers similar to\n  /// <c>System.Web.Mvc.Html.EditorExtensions.EditorForModel(HtmlHelper, String)</c>.\n  /// </summary>\n  [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property)]\n  public sealed class AspMvcEditorTemplateAttribute : Attribute { }\n\n  /// <summary>\n  /// ASP.NET MVC attribute. Indicates that the marked parameter is an MVC template.\n  /// Use this attribute for custom wrappers similar to\n  /// <c>System.ComponentModel.DataAnnotations.UIHintAttribute(System.String)</c>.\n  /// </summary>\n  [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property)]\n  public sealed class AspMvcTemplateAttribute : Attribute { }\n\n  /// <summary>\n  /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter\n  /// is an MVC view component. If applied to a method, the MVC view name is calculated implicitly\n  /// from the context. Use this attribute for custom wrappers similar to\n  /// <c>System.Web.Mvc.Controller.View(Object)</c>.\n  /// </summary>\n  [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method | AttributeTargets.Field | AttributeTargets.Property)]\n  public sealed class AspMvcViewAttribute : Attribute { }\n\n  /// <summary>\n  /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter\n  /// is an MVC view component name.\n  /// </summary>\n  [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property)]\n  public sealed class AspMvcViewComponentAttribute : Attribute { }\n\n  /// <summary>\n  /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter\n  /// is an MVC view component view. If applied to a method, the MVC view component view name is default.\n  /// </summary>\n  [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method | AttributeTargets.Field | AttributeTargets.Property)]\n  public sealed class AspMvcViewComponentViewAttribute : Attribute { }\n\n  /// <summary>\n  /// ASP.NET MVC attribute. When applied to a parameter of an attribute,\n  /// indicates that this parameter is an MVC action name.\n  /// </summary>\n  /// <example><code>\n  /// [ActionName(\"Foo\")]\n  /// public ActionResult Login(string returnUrl) {\n  ///   ViewBag.ReturnUrl = Url.Action(\"Foo\"); // OK\n  ///   return RedirectToAction(\"Bar\"); // Error: Cannot resolve action\n  /// }\n  /// </code></example>\n  [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Property)]\n  public sealed class AspMvcActionSelectorAttribute : Attribute { }\n\n  [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.Field)]\n  public sealed class HtmlElementAttributesAttribute : Attribute\n  {\n    public HtmlElementAttributesAttribute() { }\n\n    public HtmlElementAttributesAttribute([NotNull] string name)\n    {\n      Name = name;\n    }\n\n    [CanBeNull] public string Name { get; }\n  }\n\n  [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property)]\n  public sealed class HtmlAttributeValueAttribute : Attribute\n  {\n    public HtmlAttributeValueAttribute([NotNull] string name)\n    {\n      Name = name;\n    }\n\n    [NotNull] public string Name { get; }\n  }\n\n  /// <summary>\n  /// Razor attribute. Indicates that the marked parameter or method is a Razor section.\n  /// Use this attribute for custom wrappers similar to\n  /// <c>System.Web.WebPages.WebPageBase.RenderSection(String)</c>.\n  /// </summary>\n  [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)]\n  public sealed class RazorSectionAttribute : Attribute { }\n\n  /// <summary>\n  /// Indicates how method, constructor invocation, or property access\n  /// over collection type affects the contents of the collection.\n  /// Use <see cref=\"CollectionAccessType\"/> to specify the access type.\n  /// </summary>\n  /// <remarks>\n  /// Using this attribute only makes sense if all collection methods are marked with this attribute.\n  /// </remarks>\n  /// <example><code>\n  /// public class MyStringCollection : List&lt;string&gt;\n  /// {\n  ///   [CollectionAccess(CollectionAccessType.Read)]\n  ///   public string GetFirstString()\n  ///   {\n  ///     return this.ElementAt(0);\n  ///   }\n  /// }\n  /// class Test\n  /// {\n  ///   public void Foo()\n  ///   {\n  ///     // Warning: Contents of the collection is never updated\n  ///     var col = new MyStringCollection();\n  ///     string x = col.GetFirstString();\n  ///   }\n  /// }\n  /// </code></example>\n  [AttributeUsage(AttributeTargets.Method | AttributeTargets.Constructor | AttributeTargets.Property)]\n  public sealed class CollectionAccessAttribute : Attribute\n  {\n    public CollectionAccessAttribute(CollectionAccessType collectionAccessType)\n    {\n      CollectionAccessType = collectionAccessType;\n    }\n\n    public CollectionAccessType CollectionAccessType { get; }\n  }\n\n  /// <summary>\n  /// Provides a value for the <see cref=\"CollectionAccessAttribute\"/> to define\n  /// how the collection method invocation affects the contents of the collection.\n  /// </summary>\n  [Flags]\n  public enum CollectionAccessType\n  {\n    /// <summary>Method does not use or modify content of the collection.</summary>\n    None = 0,\n    /// <summary>Method only reads content of the collection but does not modify it.</summary>\n    Read = 1,\n    /// <summary>Method can change content of the collection but does not add new elements.</summary>\n    ModifyExistingContent = 2,\n    /// <summary>Method can add new elements to the collection.</summary>\n    UpdatedContent = ModifyExistingContent | 4\n  }\n\n  /// <summary>\n  /// Indicates that the marked method is assertion method, i.e. it halts the control flow if\n  /// one of the conditions is satisfied. To set the condition, mark one of the parameters with\n  /// <see cref=\"AssertionConditionAttribute\"/> attribute.\n  /// </summary>\n  [AttributeUsage(AttributeTargets.Method)]\n  public sealed class AssertionMethodAttribute : Attribute { }\n\n  /// <summary>\n  /// Indicates the condition parameter of the assertion method. The method itself should be\n  /// marked by <see cref=\"AssertionMethodAttribute\"/> attribute. The mandatory argument of\n  /// the attribute is the assertion type.\n  /// </summary>\n  [AttributeUsage(AttributeTargets.Parameter)]\n  public sealed class AssertionConditionAttribute : Attribute\n  {\n    public AssertionConditionAttribute(AssertionConditionType conditionType)\n    {\n      ConditionType = conditionType;\n    }\n\n    public AssertionConditionType ConditionType { get; }\n  }\n\n  /// <summary>\n  /// Specifies assertion type. If the assertion method argument satisfies the condition,\n  /// then the execution continues. Otherwise, execution is assumed to be halted.\n  /// </summary>\n  public enum AssertionConditionType\n  {\n    /// <summary>Marked parameter should be evaluated to true.</summary>\n    IS_TRUE = 0,\n    /// <summary>Marked parameter should be evaluated to false.</summary>\n    IS_FALSE = 1,\n    /// <summary>Marked parameter should be evaluated to null value.</summary>\n    IS_NULL = 2,\n    /// <summary>Marked parameter should be evaluated to not null value.</summary>\n    IS_NOT_NULL = 3,\n  }\n\n  /// <summary>\n  /// Indicates that the marked method unconditionally terminates control flow execution.\n  /// For example, it could unconditionally throw exception.\n  /// </summary>\n  [Obsolete(\"Use [ContractAnnotation('=> halt')] instead\")]\n  [AttributeUsage(AttributeTargets.Method)]\n  public sealed class TerminatesProgramAttribute : Attribute { }\n\n  /// <summary>\n  /// Indicates that method is pure LINQ method, with postponed enumeration (like Enumerable.Select,\n  /// .Where). This annotation allows inference of [InstantHandle] annotation for parameters\n  /// of delegate type by analyzing LINQ method chains.\n  /// </summary>\n  [AttributeUsage(AttributeTargets.Method)]\n  public sealed class LinqTunnelAttribute : Attribute { }\n\n  /// <summary>\n  /// Indicates that IEnumerable passed as a parameter is not enumerated.\n  /// Use this annotation to suppress the 'Possible multiple enumeration of IEnumerable' inspection.\n  /// </summary>\n  /// <example><code>\n  /// static void ThrowIfNull&lt;T&gt;([NoEnumeration] T v, string n) where T : class\n  /// {\n  ///   // custom check for null but no enumeration\n  /// }\n  /// \n  /// void Foo(IEnumerable&lt;string&gt; values)\n  /// {\n  ///   ThrowIfNull(values, nameof(values));\n  ///   var x = values.ToList(); // No warnings about multiple enumeration\n  /// }\n  /// </code></example>\n  [AttributeUsage(AttributeTargets.Parameter)]\n  public sealed class NoEnumerationAttribute : Attribute { }\n\n  /// <summary>\n  /// Indicates that the marked parameter is a regular expression pattern.\n  /// </summary>\n  [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property)]\n  public sealed class RegexPatternAttribute : Attribute { }\n\n  /// <summary>\n  /// Prevents the Member Reordering feature from tossing members of the marked class.\n  /// </summary>\n  /// <remarks>\n  /// The attribute must be mentioned in your member reordering patterns.\n  /// </remarks>\n  [AttributeUsage(\n    AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.Struct | AttributeTargets.Enum)]\n  public sealed class NoReorderAttribute : Attribute { }\n\n  /// <summary>\n  /// XAML attribute. Indicates the type that has <c>ItemsSource</c> property and should be treated\n  /// as <c>ItemsControl</c>-derived type, to enable inner items <c>DataContext</c> type resolve.\n  /// </summary>\n  [AttributeUsage(AttributeTargets.Class)]\n  public sealed class XamlItemsControlAttribute : Attribute { }\n\n  /// <summary>\n  /// XAML attribute. Indicates the property of some <c>BindingBase</c>-derived type, that\n  /// is used to bind some item of <c>ItemsControl</c>-derived type. This annotation will\n  /// enable the <c>DataContext</c> type resolve for XAML bindings for such properties.\n  /// </summary>\n  /// <remarks>\n  /// Property should have the tree ancestor of the <c>ItemsControl</c> type or\n  /// marked with the <see cref=\"XamlItemsControlAttribute\"/> attribute.\n  /// </remarks>\n  [AttributeUsage(AttributeTargets.Property)]\n  public sealed class XamlItemBindingOfItemsControlAttribute : Attribute { }\n\n  /// <summary>\n  /// XAML attribute. Indicates the property of some <c>Style</c>-derived type, that\n  /// is used to style items of <c>ItemsControl</c>-derived type. This annotation will\n  /// enable the <c>DataContext</c> type resolve for XAML bindings for such properties.\n  /// </summary>\n  /// <remarks>\n  /// Property should have the tree ancestor of the <c>ItemsControl</c> type or\n  /// marked with the <see cref=\"XamlItemsControlAttribute\"/> attribute.\n  /// </remarks>\n  [AttributeUsage(AttributeTargets.Property)]\n  public sealed class XamlItemStyleOfItemsControlAttribute : Attribute { }\n\n  [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]\n  public sealed class AspChildControlTypeAttribute : Attribute\n  {\n    public AspChildControlTypeAttribute([NotNull] string tagName, [NotNull] Type controlType)\n    {\n      TagName = tagName;\n      ControlType = controlType;\n    }\n\n    [NotNull] public string TagName { get; }\n\n    [NotNull] public Type ControlType { get; }\n  }\n\n  [AttributeUsage(AttributeTargets.Property | AttributeTargets.Method)]\n  public sealed class AspDataFieldAttribute : Attribute { }\n\n  [AttributeUsage(AttributeTargets.Property | AttributeTargets.Method)]\n  public sealed class AspDataFieldsAttribute : Attribute { }\n\n  [AttributeUsage(AttributeTargets.Property)]\n  public sealed class AspMethodPropertyAttribute : Attribute { }\n\n  [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]\n  public sealed class AspRequiredAttributeAttribute : Attribute\n  {\n    public AspRequiredAttributeAttribute([NotNull] string attribute)\n    {\n      Attribute = attribute;\n    }\n\n    [NotNull] public string Attribute { get; }\n  }\n\n  [AttributeUsage(AttributeTargets.Property)]\n  public sealed class AspTypePropertyAttribute : Attribute\n  {\n    public bool CreateConstructorReferences { get; }\n\n    public AspTypePropertyAttribute(bool createConstructorReferences)\n    {\n      CreateConstructorReferences = createConstructorReferences;\n    }\n  }\n\n  [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]\n  public sealed class RazorImportNamespaceAttribute : Attribute\n  {\n    public RazorImportNamespaceAttribute([NotNull] string name)\n    {\n      Name = name;\n    }\n\n    [NotNull] public string Name { get; }\n  }\n\n  [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]\n  public sealed class RazorInjectionAttribute : Attribute\n  {\n    public RazorInjectionAttribute([NotNull] string type, [NotNull] string fieldName)\n    {\n      Type = type;\n      FieldName = fieldName;\n    }\n\n    [NotNull] public string Type { get; }\n\n    [NotNull] public string FieldName { get; }\n  }\n\n  [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]\n  public sealed class RazorDirectiveAttribute : Attribute\n  {\n    public RazorDirectiveAttribute([NotNull] string directive)\n    {\n      Directive = directive;\n    }\n\n    [NotNull] public string Directive { get; }\n  }\n\n  [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]\n  public sealed class RazorPageBaseTypeAttribute : Attribute\n  {\n      public RazorPageBaseTypeAttribute([NotNull] string baseType)\n      {\n        BaseType = baseType;\n      }\n      public RazorPageBaseTypeAttribute([NotNull] string baseType, string pageName)\n      {\n          BaseType = baseType;\n          PageName = pageName;\n      }\n\n      [NotNull] public string BaseType { get; }\n      [CanBeNull] public string PageName { get; }\n  }\n\n  [AttributeUsage(AttributeTargets.Method)]\n  public sealed class RazorHelperCommonAttribute : Attribute { }\n\n  [AttributeUsage(AttributeTargets.Property)]\n  public sealed class RazorLayoutAttribute : Attribute { }\n\n  [AttributeUsage(AttributeTargets.Method)]\n  public sealed class RazorWriteLiteralMethodAttribute : Attribute { }\n\n  [AttributeUsage(AttributeTargets.Method)]\n  public sealed class RazorWriteMethodAttribute : Attribute { }\n\n  [AttributeUsage(AttributeTargets.Parameter)]\n  public sealed class RazorWriteMethodParameterAttribute : Attribute { }\n}\n"
  },
  {
    "path": "App.xaml",
    "content": "﻿<Application x:Class=\"fs2ff.App\"\n             xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\"\n             xmlns:d=\"http://schemas.microsoft.com/expression/blend/2008\"\n             xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\"\n             xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\"\n             xmlns:local=\"clr-namespace:fs2ff\"\n             xmlns:ui=\"http://schemas.modernwpf.com/2019\"\n             StartupUri=\"MainWindow.xaml\"\n             mc:Ignorable=\"d\">\n    <Application.Resources>\n        <ResourceDictionary x:Key=\"Resources\">\n            <local:ViewModelLocator x:Key=\"Locator\" d:IsDataSource=\"True\" />\n            <ResourceDictionary.MergedDictionaries>\n                <ResourceDictionary Source=\"Resources.xaml\" />\n                <ui:ThemeResources RequestedTheme=\"Dark\">\n                    <ui:ThemeResources.ThemeDictionaries>\n                        <ResourceDictionary x:Key=\"Dark\">\n                            <ResourceDictionary.MergedDictionaries>\n                                <ui:ColorPaletteResources\n                                    TargetTheme=\"Dark\"\n                                    Accent=\"Goldenrod\"\n                                    AltHigh=\"#FF232323\" />\n                            </ResourceDictionary.MergedDictionaries>\n                        </ResourceDictionary>\n                    </ui:ThemeResources.ThemeDictionaries>\n                </ui:ThemeResources>\n                <ui:XamlControlsResources />\n            </ResourceDictionary.MergedDictionaries>\n        </ResourceDictionary>\n    </Application.Resources>\n</Application>\n"
  },
  {
    "path": "App.xaml.cs",
    "content": "﻿using System;\nusing System.Reflection;\nusing System.Windows;\nusing fs2ff.SimConnect;\nusing Microsoft.Extensions.DependencyInjection;\nusing Microsoft.Extensions.Hosting;\n\nnamespace fs2ff\n{\n    /// <summary>\n    /// Interaction logic for App.xaml\n    /// </summary>\n    public partial class App\n    {\n        private static readonly IHost Host = new HostBuilder()\n            .ConfigureServices(ConfigureServices)\n            .Build();\n\n        protected override async void OnExit(ExitEventArgs e)\n        {\n            await Host.StopAsync(TimeSpan.FromSeconds(3));\n            Host.Dispose();\n            base.OnExit(e);\n        }\n\n        protected override async void OnStartup(StartupEventArgs e)\n        {\n            await Host.StartAsync();\n            base.OnStartup(e);\n        }\n\n        public static Version AssemblyVersion => Assembly.GetEntryAssembly()!.GetName().Version!;\n\n        public static string InformationalVersion => \"v\" + (Assembly\n            .GetEntryAssembly()?\n            .GetCustomAttribute<AssemblyInformationalVersionAttribute>()?\n            .InformationalVersion ?? \"0.0.0\");\n\n        public static T GetRequiredService<T>() where T : class => Host.Services.GetRequiredService<T>();\n\n        public static void ConfigureServices(IServiceCollection services)\n        {\n            services.AddSingleton<MainViewModel>();\n            services.AddSingleton<SimConnectAdapter>();\n            services.AddSingleton<DataSender>();\n            services.AddSingleton<IpDetectionService>();\n            services.AddHostedService(provider => provider.GetRequiredService<IpDetectionService>());\n        }\n    }\n}\n"
  },
  {
    "path": "AssemblyInfo.cs",
    "content": "﻿using System.Windows;\n\n[assembly:ThemeInfo(\n    ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located\n                                     //(used if a resource is not found in the page,\n                                     // or application resource dictionaries)\n    ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located\n                                              //(used if a resource is not found in the page,\n                                              // app, or any theme specific resource dictionaries)\n)]\n"
  },
  {
    "path": "Behaviors/MoveFocusOnEnterBehavior.cs",
    "content": "using System.Windows;\nusing System.Windows.Input;\nusing Microsoft.Xaml.Behaviors;\n\nnamespace fs2ff.Behaviors\n{\n    public class MoveFocusOnEnterBehavior : Behavior<UIElement>\n    {\n        protected override void OnAttached()\n        {\n            base.OnAttached();\n\n            if (AssociatedObject != null)\n                AssociatedObject.KeyDown += AssociatedObject_KeyDown;\n        }\n\n        protected override void OnDetaching()\n        {\n            if (AssociatedObject != null)\n                AssociatedObject.KeyDown -= AssociatedObject_KeyDown;\n\n            base.OnDetaching();\n        }\n\n        private static void AssociatedObject_KeyDown(object sender, KeyEventArgs e)\n        {\n            if (sender is UIElement element && e.Key == Key.Return)\n                element.MoveFocus(new TraversalRequest(FocusNavigationDirection.Next));\n        }\n    }\n}\n"
  },
  {
    "path": "Behaviors/UpdateSourceOnLostFocusBehavior.cs",
    "content": "using System.Windows;\nusing System.Windows.Controls;\nusing System.Windows.Data;\nusing Microsoft.Xaml.Behaviors;\n\nnamespace fs2ff.Behaviors\n{\n    public class UpdateSourceOnLostFocusBehavior : Behavior<TextBox>\n    {\n        protected override void OnAttached()\n        {\n            base.OnAttached();\n\n            if (AssociatedObject != null)\n                AssociatedObject.LostFocus += AssociatedObject_LostFocus;\n        }\n\n        protected override void OnDetaching()\n        {\n            if (AssociatedObject != null)\n                AssociatedObject.LostFocus -= AssociatedObject_LostFocus;\n\n            base.OnDetaching();\n        }\n\n        private static void AssociatedObject_LostFocus(object sender, RoutedEventArgs e)\n        {\n            if (sender is TextBox textBox)\n                BindingOperations.GetBindingExpression(textBox, TextBox.TextProperty)?.UpdateSource();\n        }\n    }\n}\n"
  },
  {
    "path": "Converters/BooleanToDoubleConverter.cs",
    "content": "using System;\nusing System.Globalization;\nusing System.Linq;\nusing System.Windows.Data;\nusing System.Windows.Markup;\n\nnamespace fs2ff.Converters\n{\n    public class BooleanToDoubleConverter : MarkupExtension, IValueConverter\n    {\n        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)\n        {\n            if (!(value is bool val))\n                throw new InvalidOperationException($\"{nameof(value)} must be a {nameof(Boolean)}\");\n\n            var doubles = parameter.ToString()?.Split(',').Select(double.Parse).ToArray() ?? new double[0];\n\n            if (doubles.Length != 2)\n                throw new InvalidOperationException($\"{nameof(parameter)} must be two comma-separated integer values\");\n\n            return val\n                ? doubles[0]\n                : doubles[1];\n        }\n\n        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)\n        {\n            throw new NotImplementedException();\n        }\n\n        public override object ProvideValue(IServiceProvider serviceProvider)\n        {\n            return this;\n        }\n    }\n}\n"
  },
  {
    "path": "Converters/BooleanToVisibilityConverter.cs",
    "content": "using System;\nusing System.Globalization;\nusing System.Windows;\nusing System.Windows.Data;\nusing System.Windows.Markup;\n\nnamespace fs2ff.Converters\n{\n    public class BooleanToVisibilityConverter : MarkupExtension, IValueConverter\n    {\n        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)\n        {\n            return value is bool visible && visible\n                ? Visibility.Visible\n                : parameter is Visibility vis\n                    ? vis\n                    : Visibility.Collapsed;\n        }\n\n        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)\n        {\n            return value is Visibility vis\n                ? vis == Visibility.Visible\n                : Binding.DoNothing;\n        }\n\n        public override object ProvideValue(IServiceProvider serviceProvider)\n        {\n            return this;\n        }\n    }\n}\n"
  },
  {
    "path": "Converters/FormatStringConverter.cs",
    "content": "using System;\nusing System.Globalization;\nusing System.Windows.Data;\nusing System.Windows.Markup;\n\nnamespace fs2ff.Converters\n{\n    public class FormatStringConverter : MarkupExtension, IValueConverter\n    {\n        public object Convert(object value, Type targetType, object? parameter, CultureInfo culture)\n        {\n            return parameter is string format\n                ? string.Format(format, value)\n                : value;\n        }\n\n        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)\n        {\n            throw new NotImplementedException();\n        }\n\n        public override object ProvideValue(IServiceProvider serviceProvider)\n        {\n            return this;\n        }\n    }\n}\n"
  },
  {
    "path": "Converters/InvertedBooleanConverter.cs",
    "content": "using System;\nusing System.Globalization;\nusing System.Windows.Data;\nusing System.Windows.Markup;\n\nnamespace fs2ff.Converters\n{\n    public class InvertedBooleanConverter : MarkupExtension, IValueConverter\n    {\n        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)\n        {\n            return !(bool)value;\n        }\n\n        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)\n        {\n            return !(bool)value;\n        }\n\n        public override object ProvideValue(IServiceProvider serviceProvider)\n        {\n            return this;\n        }\n    }\n}\n"
  },
  {
    "path": "Converters/IpAddressToStringConverter.cs",
    "content": "using System;\nusing System.Globalization;\nusing System.Net;\nusing System.Text.RegularExpressions;\nusing System.Windows.Data;\nusing System.Windows.Markup;\n\nnamespace fs2ff.Converters\n{\n    public class IpAddressToStringConverter : MarkupExtension, IValueConverter\n    {\n        private readonly Regex _regex = new Regex(@\"^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$\");\n\n        public object Convert(object? value, Type targetType, object parameter, CultureInfo culture)\n        {\n            if (!(value is IPAddress ip))\n                return \"\";\n\n            return Equals(ip, IPAddress.Any)\n                ? \"\"\n                : ip.ToString();\n        }\n\n        public object? ConvertBack(object? value, Type targetType, object parameter, CultureInfo culture)\n        {\n            if (value == null)\n                return null;\n\n            if (!(value is string str))\n                return Binding.DoNothing;\n\n            if (str == \"\")\n                return null;\n\n            if (!_regex.IsMatch(str))\n                return Binding.DoNothing;\n\n            return IPAddress.TryParse(str, out var result)\n                ? result\n                : Binding.DoNothing;\n        }\n\n        public override object ProvideValue(IServiceProvider serviceProvider)\n        {\n            return this;\n        }\n    }\n}\n"
  },
  {
    "path": "Converters/UIntToDoubleConverter.cs",
    "content": "using System;\nusing System.Globalization;\nusing System.Windows.Data;\nusing System.Windows.Markup;\n\nnamespace fs2ff.Converters\n{\n    public class UIntToDoubleConverter : MarkupExtension, IValueConverter\n    {\n        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)\n        {\n            return value is uint i\n                ? (double)i\n                : Binding.DoNothing;\n        }\n\n        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)\n        {\n            return value is double d\n                ? (int)Math.Round(d)\n                : Binding.DoNothing;\n        }\n\n        public override object ProvideValue(IServiceProvider serviceProvider)\n        {\n            return this;\n        }\n    }\n}\n"
  },
  {
    "path": "DataSender.cs",
    "content": "﻿using System;\nusing System.Globalization;\nusing System.Net;\nusing System.Net.Sockets;\nusing System.Text;\nusing System.Threading.Tasks;\nusing fs2ff.Models;\n\nnamespace fs2ff\n{\n    public class DataSender : IDisposable\n    {\n        private const int Port = 49002;\n        private const string SimId = \"MSFS\";\n\n        private IPEndPoint? _endPoint;\n        private Socket? _socket;\n\n        public void Connect(IPAddress? ip)\n        {\n            Disconnect();\n\n            ip ??= IPAddress.Broadcast;\n\n            _endPoint = new IPEndPoint(ip, Port);\n            _socket = new Socket(_endPoint.Address.AddressFamily, SocketType.Dgram, ProtocolType.Udp)\n            {\n                EnableBroadcast = ip.Equals(IPAddress.Broadcast)\n            };\n        }\n\n        public void Disconnect() => _socket?.Dispose();\n\n        public void Dispose() => _socket?.Dispose();\n\n        public async Task Send(Attitude a)\n        {\n            var data = string.Format(CultureInfo.InvariantCulture,\n                \"XATT{0},{1:0.#},{2:0.#},{3:0.#},,,,,,,,,\", // Garmin Pilot requires 13 fields\n                SimId, a.TrueHeading, -a.Pitch, -a.Bank);\n\n            await Send(data).ConfigureAwait(false);\n        }\n\n        public async Task Send(Position p)\n        {\n            var data = string.Format(CultureInfo.InvariantCulture,\n                \"XGPS{0},{1:0.#####},{2:0.#####},{3:0.#},{4:0.###},{5:0.#}\",\n                SimId, p.Longitude, p.Latitude, p.Altitude, p.GroundTrack, p.GroundSpeed);\n\n            await Send(data).ConfigureAwait(false);\n        }\n\n        public async Task Send(Traffic t, uint id)\n        {\n            var data = string.Format(CultureInfo.InvariantCulture,\n                \"XTRAFFIC{0},{1},{2:0.#####},{3:0.#####},{4:0.#},{5:0.#},{6},{7:0.###},{8:0.#},{9}\",\n                SimId, id, t.Latitude, t.Longitude, t.Altitude, t.VerticalSpeed, t.OnGround ? 0 : 1,\n                t.TrueHeading, t.GroundVelocity, TryGetFlightNumber(t) ?? t.TailNumber);\n\n            await Send(data).ConfigureAwait(false);\n        }\n\n        private async Task Send(string data)\n        {\n            if (_endPoint != null && _socket != null)\n            {\n                await _socket\n                    .SendToAsync(new ArraySegment<byte>(Encoding.ASCII.GetBytes(data)), SocketFlags.None, _endPoint)\n                    .ConfigureAwait(false);\n            }\n        }\n\n        private static string? TryGetFlightNumber(Traffic t) =>\n            !string.IsNullOrEmpty(t.Airline) && !string.IsNullOrEmpty(t.FlightNumber)\n                ? $\"{t.Airline} {t.FlightNumber}\"\n                : null;\n    }\n}\n"
  },
  {
    "path": "Extensions.cs",
    "content": "﻿using System;\nusing System.Threading.Tasks;\n\nnamespace fs2ff\n{\n    public static class Extensions\n    {\n        public static T AdjustToBounds<T>(this T value, T min, T max) where T : IComparable =>\n            value.CompareTo(min) < 0\n                ? min\n                : value.CompareTo(max) > 0\n                    ? max\n                    : value;\n\n        public static async Task RaiseAsync<T>(this Func<T, Task>? handler, T value)\n        {\n            if (handler == null)\n            {\n                return;\n            }\n\n            Delegate[] delegates = handler.GetInvocationList();\n            Task[] tasks = new Task[delegates.Length];\n\n            for (var i = 0; i < delegates.Length; i++)\n            {\n                tasks[i] = ((Func<T, Task>) delegates[i])(value);\n            }\n\n            await Task.WhenAll(tasks);\n        }\n\n        public static async Task RaiseAsync<T1, T2>(this Func<T1, T2, Task>? handler, T1 value1, T2 value2)\n        {\n            if (handler == null)\n            {\n                return;\n            }\n\n            Delegate[] delegates = handler.GetInvocationList();\n            Task[] tasks = new Task[delegates.Length];\n\n            for (var i = 0; i < delegates.Length; i++)\n            {\n                tasks[i] = ((Func<T1, T2, Task>) delegates[i])(value1, value2);\n            }\n\n            await Task.WhenAll(tasks);\n        }\n    }\n}\n"
  },
  {
    "path": "FodyWeavers.xml",
    "content": "﻿<Weavers xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"FodyWeavers.xsd\">\n  <PropertyChanged />\n</Weavers>"
  },
  {
    "path": "FodyWeavers.xsd",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">\n  <!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. -->\n  <xs:element name=\"Weavers\">\n    <xs:complexType>\n      <xs:all>\n        <xs:element name=\"PropertyChanged\" minOccurs=\"0\" maxOccurs=\"1\">\n          <xs:complexType>\n            <xs:attribute name=\"InjectOnPropertyNameChanged\" type=\"xs:boolean\">\n              <xs:annotation>\n                <xs:documentation>Used to control if the On_PropertyName_Changed feature is enabled.</xs:documentation>\n              </xs:annotation>\n            </xs:attribute>\n            <xs:attribute name=\"TriggerDependentProperties\" type=\"xs:boolean\">\n              <xs:annotation>\n                <xs:documentation>Used to control if the Dependent properties feature is enabled.</xs:documentation>\n              </xs:annotation>\n            </xs:attribute>\n            <xs:attribute name=\"EnableIsChangedProperty\" type=\"xs:boolean\">\n              <xs:annotation>\n                <xs:documentation>Used to control if the IsChanged property feature is enabled.</xs:documentation>\n              </xs:annotation>\n            </xs:attribute>\n            <xs:attribute name=\"EventInvokerNames\" type=\"xs:string\">\n              <xs:annotation>\n                <xs:documentation>Used to change the name of the method that fires the notify event. This is a string that accepts multiple values in a comma separated form.</xs:documentation>\n              </xs:annotation>\n            </xs:attribute>\n            <xs:attribute name=\"CheckForEquality\" type=\"xs:boolean\">\n              <xs:annotation>\n                <xs:documentation>Used to control if equality checks should be inserted. If false, equality checking will be disabled for the project.</xs:documentation>\n              </xs:annotation>\n            </xs:attribute>\n            <xs:attribute name=\"CheckForEqualityUsingBaseEquals\" type=\"xs:boolean\">\n              <xs:annotation>\n                <xs:documentation>Used to control if equality checks should use the Equals method resolved from the base class.</xs:documentation>\n              </xs:annotation>\n            </xs:attribute>\n            <xs:attribute name=\"UseStaticEqualsFromBase\" type=\"xs:boolean\">\n              <xs:annotation>\n                <xs:documentation>Used to control if equality checks should use the static Equals method resolved from the base class.</xs:documentation>\n              </xs:annotation>\n            </xs:attribute>\n            <xs:attribute name=\"SuppressWarnings\" type=\"xs:boolean\">\n              <xs:annotation>\n                <xs:documentation>Used to turn off build warnings from this weaver.</xs:documentation>\n              </xs:annotation>\n            </xs:attribute>\n            <xs:attribute name=\"SuppressOnPropertyNameChangedWarning\" type=\"xs:boolean\">\n              <xs:annotation>\n                <xs:documentation>Used to turn off build warnings about mismatched On_PropertyName_Changed methods.</xs:documentation>\n              </xs:annotation>\n            </xs:attribute>\n          </xs:complexType>\n        </xs:element>\n      </xs:all>\n      <xs:attribute name=\"VerifyAssembly\" type=\"xs:boolean\">\n        <xs:annotation>\n          <xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation>\n        </xs:annotation>\n      </xs:attribute>\n      <xs:attribute name=\"VerifyIgnoreCodes\" type=\"xs:string\">\n        <xs:annotation>\n          <xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation>\n        </xs:annotation>\n      </xs:attribute>\n      <xs:attribute name=\"GenerateXsd\" type=\"xs:boolean\">\n        <xs:annotation>\n          <xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation>\n        </xs:annotation>\n      </xs:attribute>\n    </xs:complexType>\n  </xs:element>\n</xs:schema>"
  },
  {
    "path": "IpDetectionService.cs",
    "content": "using System;\nusing System.Net;\nusing System.Net.Sockets;\nusing System.Text;\nusing System.Text.Json;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing Microsoft.Extensions.Hosting;\n\nnamespace fs2ff\n{\n    public class IpDetectionService : IHostedService\n    {\n        private const int Port = 63093;\n\n        public event Action<IPAddress>? NewIpDetected;\n\n        public async Task StartAsync(CancellationToken cancellationToken)\n        {\n            await Task.Run(async () =>\n            {\n                try\n                {\n                    using var udpClient = new UdpClient(Port, IPAddress.Any.AddressFamily);\n\n                    while (!cancellationToken.IsCancellationRequested)\n                    {\n                        var result = await udpClient.ReceiveAsync();\n                        var text = Encoding.ASCII.GetString(result.Buffer);\n\n                        if (IsForeFlightGdl90(text))\n                        {\n                            NewIpDetected?.Invoke(result.RemoteEndPoint.Address);\n                        }\n                    }\n                }\n                catch (SocketException e)\n                {\n                    Console.Error.WriteLine(e);\n                }\n            }, cancellationToken);\n        }\n\n        public Task StopAsync(CancellationToken cancellationToken) => Task.CompletedTask;\n\n        private static bool IsForeFlightGdl90(string text)\n        {\n            try\n            {\n                return JsonDocument.Parse(text).RootElement.TryGetProperty(\"App\", out var app) &&\n                       app.GetString() == \"ForeFlight\";\n            }\n            catch (Exception)\n            {\n                return false;\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "LICENSE",
    "content": "This is free and unencumbered software released into the public domain.\n\nAnyone is free to copy, modify, publish, use, compile, sell, or\ndistribute this software, either in source code form or as a compiled\nbinary, for any purpose, commercial or non-commercial, and by any\nmeans.\n\nIn jurisdictions that recognize copyright laws, the author or authors\nof this software dedicate any and all copyright interest in the\nsoftware to the public domain. We make this dedication for the benefit\nof the public at large and to the detriment of our heirs and\nsuccessors. We intend this dedication to be an overt act of\nrelinquishment in perpetuity of all present and future rights to this\nsoftware under copyright law.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR\nOTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,\nARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\nOTHER DEALINGS IN THE SOFTWARE.\n\nFor more information, please refer to <https://unlicense.org>\n"
  },
  {
    "path": "MainViewModel.cs",
    "content": "﻿using System;\nusing System.ComponentModel;\nusing System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Net;\nusing System.Threading.Tasks;\nusing System.Windows.Input;\nusing System.Windows.Threading;\nusing fs2ff.Models;\nusing fs2ff.SimConnect;\n\n#pragma warning disable 67\n\nnamespace fs2ff\n{\n    [SuppressMessage(\"ReSharper\", \"NotAccessedField.Local\", Justification = \"DispatcherTimer field is kept to prevent premature GC\")]\n    public class MainViewModel : INotifyPropertyChanged, ISimConnectMessageHandler\n    {\n        private readonly DataSender _dataSender;\n        private readonly SimConnectAdapter _simConnect;\n        private readonly IpDetectionService _ipDetectionService;\n        private readonly DispatcherTimer _ipHintTimer;\n        private readonly DispatcherTimer _autoConnectTimer;\n\n        private uint _attitudeFrequency = Preferences.Default.att_freq.AdjustToBounds(AttitudeFrequencyMin, AttitudeFrequencyMax);\n        private bool _autoDetectIpEnabled = Preferences.Default.ip_detection_enabled;\n        private bool _autoConnectEnabled = Preferences.Default.auto_connect_enabled;\n        private bool _dataAttitudeEnabled = Preferences.Default.att_enabled;\n        private bool _dataPositionEnabled = Preferences.Default.pos_enabled;\n        private bool _dataTrafficEnabled = Preferences.Default.tfk_enabled;\n        private bool _errorOccurred;\n        private IntPtr _hwnd = IntPtr.Zero;\n        private IPAddress? _ipAddress;\n        private uint _ipHintMinutesLeft = Preferences.Default.ip_hint_time;\n\n        public MainViewModel(DataSender dataSender, SimConnectAdapter simConnect, IpDetectionService ipDetectionService)\n        {\n            _dataSender = dataSender;\n\n            _simConnect = simConnect;\n            _simConnect.StateChanged += SimConnectStateChanged;\n            _simConnect.PositionReceived += SimConnectPositionReceived;\n            _simConnect.AttitudeReceived += SimConnectAttitudeReceived;\n            _simConnect.TrafficReceived += SimConnectTrafficReceived;\n\n            _ipDetectionService = ipDetectionService;\n            _ipDetectionService.NewIpDetected += IpDetectionService_NewIpDetected;\n\n            OpenSettingsCommand = new ActionCommand(OpenSettings);\n            DismissSettingsPaneCommand = new ActionCommand(DismissSettingsPane);\n            GotoNewReleaseCommand = new ActionCommand(GotoReleaseNotesPage);\n            ToggleConnectCommand = new ActionCommand(ToggleConnect, CanConnect);\n            ToggleSettingsPaneCommand = new ActionCommand(ToggleSettingsPane);\n\n            _ipAddress = IPAddress.TryParse(Preferences.Default.ip_address, out var ip) ? ip : null;\n\n            _ipHintTimer = new DispatcherTimer(TimeSpan.FromMinutes(1), DispatcherPriority.Normal, IpHintCallback, Dispatcher.CurrentDispatcher);\n            _autoConnectTimer = new DispatcherTimer(TimeSpan.FromSeconds(5), DispatcherPriority.Normal, AutoConnectCallback, Dispatcher.CurrentDispatcher);\n\n            ManageAutoConnect();\n            CheckForUpdates();\n            UpdateVisualState();\n        }\n\n        public event PropertyChangedEventHandler? PropertyChanged;\n\n        [SuppressMessage(\"ReSharper\", \"UnusedMember.Local\", Justification = \"Unknown is not supposed to be used\")]\n        private enum FlightSimState\n        {\n            Unknown,\n            Connected,\n            Disconnected,\n            ErrorOccurred,\n            AutoConnecting\n        }\n\n        public static string WindowTitle => $\"fs2ff - {App.InformationalVersion}\";\n\n        public uint AttitudeFrequency\n        {\n            get => _attitudeFrequency;\n            set\n            {\n                _attitudeFrequency = value.AdjustToBounds(AttitudeFrequencyMin, AttitudeFrequencyMax);\n                _simConnect.SetAttitudeFrequency(_attitudeFrequency);\n                Preferences.Default.att_freq = value;\n                Preferences.Default.Save();\n            }\n        }\n\n        public static uint AttitudeFrequencyMax => 10;\n\n        public static uint AttitudeFrequencyMin => 4;\n\n        public bool AutoConnectEnabled\n        {\n            get => _autoConnectEnabled;\n            set\n            {\n                if (value != _autoConnectEnabled)\n                {\n                    _autoConnectEnabled = value;\n                    Preferences.Default.auto_connect_enabled = value;\n                    Preferences.Default.Save();\n\n                    // If auto connect was running and the sim wasn't then there is likely\n                    // an error flagged. Clear it whenever AutoConnectEnabled changes state\n                    // so in the event auto connect is disabled the window won't show\n                    // a meaningless connection error to the user.\n                    _errorOccurred = false;\n\n                    ManageAutoConnect();\n                    UpdateVisualState();\n                }\n            }\n        }\n\n        public bool AutoConnectLabelVisible { get; private set; }\n\n        public bool AutoDetectIpEnabled\n        {\n            get => _autoDetectIpEnabled;\n            set\n            {\n                if (value != _autoDetectIpEnabled)\n                {\n                    _autoDetectIpEnabled = value;\n                    Preferences.Default.ip_detection_enabled = value;\n                    Preferences.Default.Save();\n                }\n            }\n        }\n\n        public bool ConnectButtonEnabled { get => !_autoConnectEnabled; }\n\n        public string? ConnectButtonText { get; private set; }\n\n        public bool ConnectedLabelVisible { get; private set; }\n\n        public bool DataAttitudeEnabled\n        {\n            get => _dataAttitudeEnabled;\n            set\n            {\n                if (value != _dataAttitudeEnabled)\n                {\n                    _dataAttitudeEnabled = value;\n                    Preferences.Default.att_enabled = value;\n                    Preferences.Default.Save();\n                }\n            }\n        }\n\n        public bool DataPositionEnabled\n        {\n            get => _dataPositionEnabled;\n            set\n            {\n                if (value != _dataPositionEnabled)\n                {\n                    _dataPositionEnabled = value;\n                    Preferences.Default.pos_enabled = value;\n                    Preferences.Default.Save();\n                }\n            }\n        }\n\n        public bool DataTrafficEnabled\n        {\n            get => _dataTrafficEnabled;\n            set\n            {\n                if (value != _dataTrafficEnabled)\n                {\n                    _dataTrafficEnabled = value;\n                    Preferences.Default.tfk_enabled = value;\n                    Preferences.Default.Save();\n                }\n            }\n        }\n\n        public ICommand DismissSettingsPaneCommand { get; }\n\n        public bool ErrorLabelVisible { get; private set; }\n\n        public ICommand GotoNewReleaseCommand { get; }\n\n        public bool IndicatorVisible { get; private set; }\n\n        public IPAddress? IpAddress\n        {\n            get => _ipAddress;\n            set\n            {\n                if (!Equals(value, _ipAddress))\n                {\n                    _ipAddress = value;\n                    Preferences.Default.ip_address = value?.ToString() ?? \"\";\n                    Preferences.Default.Save();\n\n                    if (value != null)\n                    {\n                        ResetIpHintMinutesLeft();\n                    }\n\n                    ResetDataSenderConnection();\n                }\n            }\n        }\n\n        public bool IpHintVisible => IpAddress == null && IpHintMinutesLeft == 0;\n\n        public bool NotLabelVisible { get; private set; }\n\n        public ICommand OpenSettingsCommand { get; }\n\n        public bool SettingsPaneVisible { get; set; }\n\n        public ActionCommand ToggleConnectCommand { get; }\n\n        public ICommand ToggleSettingsPaneCommand { get; }\n\n        public bool UpdateMsgVisible => UpdateInfo != null && !SettingsPaneVisible;\n\n        public IntPtr WindowHandle\n        {\n            get => _hwnd;\n            set\n            {\n                _hwnd = value;\n                ToggleConnectCommand.TriggerCanExecuteChanged();\n            }\n        }\n\n        private FlightSimState CurrentFlightSimState =>\n            _simConnect.Connected ? FlightSimState.Connected :\n            AutoConnectEnabled ? FlightSimState.AutoConnecting :\n            _errorOccurred ? FlightSimState.ErrorOccurred :\n            FlightSimState.Disconnected;\n\n        private uint IpHintMinutesLeft\n        {\n            get => _ipHintMinutesLeft;\n            set\n            {\n                if (value != _ipHintMinutesLeft)\n                {\n                    _ipHintMinutesLeft = value;\n                    Preferences.Default.ip_hint_time = value;\n                    Preferences.Default.Save();\n                }\n            }\n        }\n\n        private UpdateInformation? UpdateInfo { get; set; }\n\n        public void Dispose()\n        {\n            _ipDetectionService.NewIpDetected -= IpDetectionService_NewIpDetected;\n\n            _simConnect.TrafficReceived -= SimConnectTrafficReceived;\n            _simConnect.AttitudeReceived -= SimConnectAttitudeReceived;\n            _simConnect.PositionReceived -= SimConnectPositionReceived;\n            _simConnect.StateChanged -= SimConnectStateChanged;\n            _simConnect.Dispose();\n\n            _dataSender.Dispose();\n        }\n\n        public void ReceiveFlightSimMessage() => _simConnect.ReceiveMessage();\n\n        private void AutoConnectCallback(object? sender, EventArgs e) => Connect();\n\n        private bool CanConnect() => WindowHandle != IntPtr.Zero;\n\n        private void CheckForUpdates()\n        {\n            UpdateChecker.Check().ContinueWith(task => UpdateInfo = task.Result, TaskScheduler.FromCurrentSynchronizationContext());\n        }\n\n        private void Connect() => _simConnect.Connect(WindowHandle, AttitudeFrequency);\n\n        private void Disconnect() => _simConnect.Disconnect();\n\n        private void DismissSettingsPane() => SettingsPaneVisible = false;\n\n\n        private void GotoReleaseNotesPage()\n        {\n            if (UpdateInfo != null)\n            {\n                Process.Start(\"explorer.exe\", UpdateInfo.DownloadLink.ToString());\n            }\n        }\n\n        private void IpDetectionService_NewIpDetected(IPAddress ip)\n        {\n            if (AutoDetectIpEnabled)\n            {\n                IpAddress = ip;\n            }\n        }\n\n        private void IpHintCallback(object? sender, EventArgs e)\n        {\n            if (IpHintMinutesLeft > 0 && IpAddress == null && _simConnect.Connected)\n            {\n                IpHintMinutesLeft--;\n            }\n        }\n\n        private void ManageAutoConnect()\n        {\n            if (!AutoConnectEnabled || CurrentFlightSimState == FlightSimState.Connected)\n            {\n                _autoConnectTimer.Stop();\n            }\n            else\n            {\n                _autoConnectTimer.Start();\n            }\n        }\n\n        private void OpenSettings() => SettingsPaneVisible = true;\n\n        private void ResetDataSenderConnection()\n        {\n            if (CurrentFlightSimState == FlightSimState.Connected)\n            {\n                _dataSender.Connect(IpAddress);\n            }\n            else\n            {\n                _dataSender.Disconnect();\n            }\n        }\n\n        private void ResetIpHintMinutesLeft()\n        {\n            Preferences.Default.PropertyValues[\"ip_hint_time\"].SerializedValue = Preferences.Default.Properties[\"ip_hint_time\"].DefaultValue;\n            Preferences.Default.PropertyValues[\"ip_hint_time\"].Deserialized = false;\n            IpHintMinutesLeft = Preferences.Default.ip_hint_time;\n        }\n\n        private async Task SimConnectAttitudeReceived(Attitude att)\n        {\n            if (DataAttitudeEnabled)\n            {\n                await _dataSender.Send(att).ConfigureAwait(false);\n            }\n        }\n\n        private async Task SimConnectPositionReceived(Position pos)\n        {\n            if (DataPositionEnabled && (pos.Latitude != 0d || pos.Longitude != 0d))\n            {\n                await _dataSender.Send(pos).ConfigureAwait(false);\n            }\n        }\n\n        private void SimConnectStateChanged(bool failure)\n        {\n            _errorOccurred = failure;\n\n            ManageAutoConnect();\n            ResetDataSenderConnection();\n            UpdateVisualState();\n        }\n\n        private async Task SimConnectTrafficReceived(Traffic tfk, uint id)\n        {\n            // Ignore traffic with id=1, that's our own aircraft\n            if (DataTrafficEnabled && id != 1)\n            {\n                await _dataSender.Send(tfk, id).ConfigureAwait(false);\n            }\n        }\n\n        private void ToggleConnect()\n        {\n            if (_simConnect.Connected) Disconnect();\n            else                          Connect();\n        }\n\n        private void ToggleSettingsPane() => SettingsPaneVisible = !SettingsPaneVisible;\n\n        private void UpdateVisualState()\n        {\n            (IndicatorVisible, AutoConnectLabelVisible, NotLabelVisible, ErrorLabelVisible, ConnectedLabelVisible, ConnectButtonText) = CurrentFlightSimState switch\n            {\n                FlightSimState.AutoConnecting => (false, true, false, false, false, \"Connect\"),\n                FlightSimState.Connected => (true, false, false, false, true, \"Disconnect\"),\n                FlightSimState.Disconnected => (false, false, true, false, true, \"Connect\"),\n                FlightSimState.ErrorOccurred => (false, false, false, true, false, \"Connect\"),\n                _ => (false, false, true, false, true, \"Connect\")\n            };\n        }\n    }\n}\n"
  },
  {
    "path": "MainWindow.xaml",
    "content": "﻿<Window x:Class=\"fs2ff.MainWindow\"\n        xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\"\n        xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\"\n        xmlns:d=\"http://schemas.microsoft.com/expression/blend/2008\"\n        xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\"\n        xmlns:ui=\"http://schemas.modernwpf.com/2019\"\n        xmlns:i=\"http://schemas.microsoft.com/xaml/behaviors\"\n        xmlns:b=\"clr-namespace:fs2ff.Behaviors\"\n        xmlns:c=\"clr-namespace:fs2ff.Converters\"\n        ui:WindowHelper.UseModernWindowStyle=\"True\"\n        mc:Ignorable=\"d\"\n        Title=\"{Binding WindowTitle}\"\n        Icon=\"img\\icon.ico\"\n        Width=\"555\" Height=\"430\"\n        MinWidth=\"555\" MinHeight=\"430\"\n        Closing=\"Window_Closing\"\n        Loaded=\"Window_Loaded\"\n        DataContext=\"{Binding Main, Source={StaticResource Locator}}\">\n    <Window.Resources>\n        <Style TargetType=\"Button\" BasedOn=\"{StaticResource {x:Type Button}}\">\n            <Setter Property=\"FontFamily\" Value=\"Segoe UI\" />\n            <Setter Property=\"FocusVisualStyle\" Value=\"{x:Null}\" />\n        </Style>\n        <Style TargetType=\"CheckBox\" BasedOn=\"{StaticResource {x:Type CheckBox}}\">\n            <Setter Property=\"Focusable\" Value=\"False\" />\n            <Setter Property=\"FontFamily\" Value=\"Segoe UI\" />\n            <Setter Property=\"FontSize\" Value=\"12\" />\n        </Style>\n        <Style TargetType=\"Hyperlink\" BasedOn=\"{StaticResource {x:Type Hyperlink}}\">\n            <Setter Property=\"Focusable\" Value=\"False\" />\n            <Setter Property=\"FontFamily\" Value=\"Segoe UI\" />\n            <Setter Property=\"FontSize\" Value=\"12\" />\n        </Style>\n        <Style TargetType=\"Label\" BasedOn=\"{StaticResource {x:Type Label}}\">\n            <Setter Property=\"FontFamily\" Value=\"Segoe UI\" />\n            <Setter Property=\"FontSize\" Value=\"12\" />\n            <Setter Property=\"FontWeight\" Value=\"SemiBold\" />\n            <Setter Property=\"Foreground\" Value=\"DarkGray\" />\n        </Style>\n        <Style TargetType=\"TextBlock\" BasedOn=\"{StaticResource {x:Type TextBlock}}\">\n            <Setter Property=\"FontFamily\" Value=\"Segoe UI\" />\n            <Setter Property=\"FontSize\" Value=\"12\" />\n        </Style>\n        <Style TargetType=\"ToggleButton\" BasedOn=\"{StaticResource {x:Type ToggleButton}}\">\n            <Setter Property=\"Focusable\" Value=\"False\" />\n            <Setter Property=\"FontFamily\" Value=\"Segoe UI\" />\n            <Setter Property=\"FontSize\" Value=\"12\" />\n        </Style>\n    </Window.Resources>\n    <Window.InputBindings>\n        <KeyBinding Key=\"Tab\" Command=\"{Binding ToggleSettingsPaneCommand}\" />\n    </Window.InputBindings>\n    <ui:SplitView\n        FocusManager.FocusedElement=\"{Binding ElementName=ConnectButton}\"\n        IsPaneOpen=\"{Binding SettingsPaneVisible}\"\n        DisplayMode=\"Inline\"\n        OpenPaneLength=\"185\"\n        PanePlacement=\"Right\">\n        <i:Interaction.Triggers>\n            <i:KeyTrigger Key=\"Escape\">\n                <i:Interaction.Behaviors>\n                    <i:ConditionBehavior>\n                        <i:ConditionalExpression>\n                            <i:ComparisonCondition\n                                LeftOperand=\"{\n                                    Binding IsPaneOpen,\n                                    RelativeSource={RelativeSource FindAncestor, AncestorType=ui:SplitView}}\"\n                                RightOperand=\"True\" />\n                        </i:ConditionalExpression>\n                    </i:ConditionBehavior>\n                </i:Interaction.Behaviors>\n                <i:InvokeCommandAction Command=\"{Binding DismissSettingsPaneCommand}\" />\n            </i:KeyTrigger>\n        </i:Interaction.Triggers>\n        <ui:SplitView.Pane>\n            <StackPanel\n                Orientation=\"Vertical\"\n                Margin=\"15,0,15,0\">\n                <CheckBox Margin=\"0,20,0,5\" \n                    IsChecked=\"{Binding AutoConnectEnabled, Mode=TwoWay}\"\n                    Content=\"Auto connect\"\n                    ToolTip=\"Automatically connects to Flight Simulator when it launches\" />\n                <Label\n                    Content=\"DEVICE IP\"\n                    Margin=\"0,20,0,5\" />\n                <CheckBox\n                    IsChecked=\"{Binding AutoDetectIpEnabled, Mode=TwoWay}\"\n                    Content=\"Auto-detect*\"\n                    ToolTip=\"Requires ForeFlight running in the foreground\" />\n                <TextBox\n                    Text=\"{\n                        Binding IpAddress, Mode=TwoWay,\n                        Converter={c:IpAddressToStringConverter},\n                        UpdateSourceTrigger=PropertyChanged, Delay=5000}\"\n                    Template=\"{StaticResource WatermarkTextBoxTemplate}\"\n                    Tag=\"255.255.255.255\"\n                    Margin=\"0,10,0,0\">\n                    <i:Interaction.Behaviors>\n                        <b:MoveFocusOnEnterBehavior />\n                        <b:UpdateSourceOnLostFocusBehavior />\n                    </i:Interaction.Behaviors>\n                </TextBox>\n                <Label\n                    Content=\"DATA SELECTION\"\n                    Margin=\"0,20,0,5\" />\n                <CheckBox\n                    IsChecked=\"{Binding DataPositionEnabled, Mode=TwoWay}\"\n                    Content=\"Position\" />\n                <CheckBox\n                    IsChecked=\"{Binding DataTrafficEnabled, Mode=TwoWay}\"\n                    Content=\"Traffic\" />\n                <CheckBox\n                    IsChecked=\"{Binding DataAttitudeEnabled, Mode=TwoWay}\"\n                    Content=\"Attitude\" />\n                <Label\n                    Content=\"{Binding Value, ElementName=Slider, Converter={c:FormatStringConverter}, ConverterParameter='ATTITUDE FREQ: {0} Hz'}\"\n                    Margin=\"0,14,0,5\" />\n                <Slider\n                    Name=\"Slider\"\n                    IsEnabled=\"{Binding DataAttitudeEnabled}\"\n                    Value=\"{Binding AttitudeFrequency, Mode=TwoWay, Delay=2000, Converter={c:UIntToDoubleConverter}}\"\n                    Minimum=\"{Binding AttitudeFrequencyMin, Converter={c:UIntToDoubleConverter}}\"\n                    Maximum=\"{Binding AttitudeFrequencyMax, Converter={c:UIntToDoubleConverter}}\"\n                    Focusable=\"False\"\n                    TickPlacement=\"Both\"\n                    IsSnapToTickEnabled=\"True\" />\n            </StackPanel>\n        </ui:SplitView.Pane>\n        <Grid>\n            <Grid.RowDefinitions>\n                <RowDefinition Height=\"*\" />\n                <RowDefinition Height=\"40\" />\n            </Grid.RowDefinitions>\n            <Grid.ColumnDefinitions>\n                <ColumnDefinition Width=\"*\" />\n                <ColumnDefinition Width=\"Auto\" />\n            </Grid.ColumnDefinitions>\n            <Label\n                Grid.Row=\"0\"\n                Grid.Column=\"0\"\n                Visibility=\"{Binding IpHintVisible, Converter={c:BooleanToVisibilityConverter}}\"\n                HorizontalAlignment=\"Center\"\n                VerticalAlignment=\"Top\"\n                FontStyle=\"Italic\"\n                Margin=\"0,30,0,0\">\n                <StackPanel Orientation=\"Vertical\">\n                    <TextBlock HorizontalAlignment=\"Center\">\n                        Device IP not set. Please set it manually or enable\n                    </TextBlock>\n                    <TextBlock HorizontalAlignment=\"Center\">\n                        auto-detect for improved performance.\n                        <Hyperlink Command=\"{Binding OpenSettingsCommand}\">Open settings.</Hyperlink>\n                    </TextBlock>\n                </StackPanel>\n            </Label>\n            <Button\n                Grid.Row=\"0\"\n                Grid.Column=\"0\"\n                Grid.RowSpan=\"2\"\n                Name=\"ConnectButton\"\n                Content=\"{Binding ConnectButtonText, FallbackValue='Connect'}\"\n                Command=\"{Binding ToggleConnectCommand}\"\n                FontSize=\"16\"\n                HorizontalAlignment=\"Center\"\n                VerticalAlignment=\"Center\"\n                Width=\"144\"\n                Height=\"60\"\n                IsEnabled=\"{Binding ConnectButtonEnabled}\" />\n            <Ellipse\n                Grid.Row=\"1\"\n                Grid.Column=\"0\"\n                Fill=\"LawnGreen\"\n                Stroke=\"ForestGreen\"\n                StrokeThickness=\"1\"\n                Width=\"10\" Height=\"10\"\n                VerticalAlignment=\"Center\"\n                HorizontalAlignment=\"Left\"\n                Visibility=\"{Binding IndicatorVisible, Converter={c:BooleanToVisibilityConverter}}\"\n                Margin=\"27,0,0,0\" />\n            <Label\n                Grid.Row=\"1\"\n                Grid.Column=\"0\"\n                Content=\"NOT\"\n                Foreground=\"DarkGray\"\n                VerticalAlignment=\"Center\"\n                HorizontalAlignment=\"Left\"\n                Visibility=\"{Binding NotLabelVisible, Converter={c:BooleanToVisibilityConverter}}\"\n                Margin=\"17,0,0,0\" />\n            <Label\n                Grid.Row=\"1\"\n                Grid.Column=\"0\"\n                Content=\"CONNECTED\"\n                Foreground=\"DarkGray\"\n                VerticalAlignment=\"Center\"\n                HorizontalAlignment=\"Left\"\n                Visibility=\"{Binding ConnectedLabelVisible, Converter={c:BooleanToVisibilityConverter}}\"\n                Margin=\"45,0,0,0\" />\n            <Label\n                Grid.Row=\"1\"\n                Grid.Column=\"0\"\n                Content=\"AUTO CONNECTING...\"\n                Foreground=\"DarkGray\"\n                VerticalAlignment=\"Center\"\n                HorizontalAlignment=\"Left\"\n                Visibility=\"{Binding AutoConnectLabelVisible, Converter={c:BooleanToVisibilityConverter}}\"\n                Margin=\"10,0,0,0\" />\n            <Label\n                Grid.Row=\"1\"\n                Grid.Column=\"0\"\n                Content=\"UNABLE TO CONNECT TO FLIGHT SIMULATOR\"\n                Foreground=\"OrangeRed\"\n                VerticalAlignment=\"Center\"\n                HorizontalAlignment=\"Left\"\n                Visibility=\"{Binding ErrorLabelVisible, Converter={c:BooleanToVisibilityConverter}}\"\n                Margin=\"17,0,0,0\" />\n            <Label\n                Grid.Row=\"1\"\n                Grid.Column=\"0\"\n                Visibility=\"{Binding UpdateMsgVisible, Converter={c:BooleanToVisibilityConverter}}\"\n                VerticalAlignment=\"Center\"\n                HorizontalAlignment=\"Right\"\n                FontStyle=\"Italic\"\n                Margin=\"15,0,25,0\">\n                <Hyperlink Command=\"{Binding GotoNewReleaseCommand}\">Update available</Hyperlink>\n            </Label>\n            <ToggleButton\n                Grid.Row=\"0\"\n                Grid.Column=\"1\"\n                Grid.RowSpan=\"2\"\n                IsChecked=\"{Binding SettingsPaneVisible, Mode=TwoWay}\"\n                VerticalAlignment=\"Stretch\"\n                Width=\"47\">\n                <ToggleButton.ContentTemplate>\n                    <DataTemplate>\n                        <Label Content=\"S   E   T   T   I   N   G   S\" Foreground=\"White\">\n                            <Label.LayoutTransform>\n                                <TransformGroup>\n                                    <RotateTransform x:Name=\"RotateTransform\" Angle=\"90\" />\n                                </TransformGroup>\n                            </Label.LayoutTransform>\n                            <i:Interaction.Triggers>\n                                <i:PropertyChangedTrigger Binding=\"{\n                                    Binding IsPaneOpen,\n                                    RelativeSource={\n                                        RelativeSource FindAncestor,\n                                        AncestorType=ui:SplitView}}\">\n                                    <i:ChangePropertyAction\n                                        TargetName=\"RotateTransform\"\n                                        PropertyName=\"Angle\">\n                                        <i:ChangePropertyAction.Value>\n                                            <Binding\n                                                Path=\"IsPaneOpen\"\n                                                RelativeSource=\"{\n                                                    RelativeSource FindAncestor,\n                                                    AncestorType=ui:SplitView}\"\n                                                Converter=\"{c:BooleanToDoubleConverter}\"\n                                                ConverterParameter=\"270,90\" />\n                                        </i:ChangePropertyAction.Value>\n                                    </i:ChangePropertyAction>\n                                </i:PropertyChangedTrigger>\n                            </i:Interaction.Triggers>\n                        </Label>\n                    </DataTemplate>\n                </ToggleButton.ContentTemplate>\n            </ToggleButton>\n        </Grid>\n    </ui:SplitView>\n</Window>\n"
  },
  {
    "path": "MainWindow.xaml.cs",
    "content": "﻿// ReSharper disable InconsistentNaming\n\nusing System;\nusing System.ComponentModel;\nusing System.Windows;\nusing System.Windows.Interop;\nusing fs2ff.SimConnect;\n\nnamespace fs2ff\n{\n    public partial class MainWindow\n    {\n        private const uint WM_USER_SIMCONNECT = 0x0402;\n\n        public MainWindow()\n        {\n            InitializeComponent();\n        }\n\n        private void Window_Closing(object sender, CancelEventArgs e)\n        {\n            ((ISimConnectMessageHandler) DataContext).Dispose();\n        }\n\n        private void Window_Loaded(object sender, RoutedEventArgs e)\n        {\n            HwndSource hwndSource = (HwndSource) PresentationSource.FromVisual(this)!;\n            hwndSource.AddHook(WndProc);\n            ((ISimConnectMessageHandler) DataContext).WindowHandle = hwndSource.Handle;\n        }\n\n        private IntPtr WndProc(IntPtr hWnd, int iMsg, IntPtr hWParam, IntPtr hLParam, ref bool bHandled)\n        {\n            if (iMsg == WM_USER_SIMCONNECT)\n            {\n                ((ISimConnectMessageHandler) DataContext).ReceiveFlightSimMessage();\n            }\n\n            return IntPtr.Zero;\n        }\n    }\n}\n"
  },
  {
    "path": "Models/Attitude.cs",
    "content": "// ReSharper disable FieldCanBeMadeReadOnly.Global\n\nusing System.Runtime.InteropServices;\n\nnamespace fs2ff.Models\n{\n    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]\n    public struct Attitude\n    {\n        public double Pitch;\n        public double Bank;\n        public double TrueHeading;\n    }\n}\n"
  },
  {
    "path": "Models/Position.cs",
    "content": "﻿// ReSharper disable FieldCanBeMadeReadOnly.Global\n\nusing System.Runtime.InteropServices;\n\nnamespace fs2ff.Models\n{\n    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]\n    public struct Position\n    {\n        public double Latitude;\n        public double Longitude;\n        public double Altitude;\n        public double GroundTrack;\n        public double GroundSpeed;\n    }\n}\n"
  },
  {
    "path": "Models/Traffic.cs",
    "content": "﻿// ReSharper disable FieldCanBeMadeReadOnly.Global\n\nusing System.Runtime.InteropServices;\n\nnamespace fs2ff.Models\n{\n    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]\n    public struct Traffic\n    {\n        public double Latitude;\n        public double Longitude;\n        public double Altitude;\n        public double VerticalSpeed;\n        public bool OnGround;\n        public double TrueHeading;\n        public double GroundVelocity;\n\n        [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 64)]\n        public string TailNumber;\n\n        [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 64)]\n        public string Airline;\n\n        [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 8)]\n        public string FlightNumber;\n    }\n}\n"
  },
  {
    "path": "Preferences.Designer.cs",
    "content": "﻿//------------------------------------------------------------------------------\n// <auto-generated>\n//     This code was generated by a tool.\n//     Runtime Version:4.0.30319.42000\n//\n//     Changes to this file may cause incorrect behavior and will be lost if\n//     the code is regenerated.\n// </auto-generated>\n//------------------------------------------------------------------------------\n\nnamespace fs2ff {\n    \n    \n    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]\n    [global::System.CodeDom.Compiler.GeneratedCodeAttribute(\"Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator\", \"16.7.0.0\")]\n    internal sealed partial class Preferences : global::System.Configuration.ApplicationSettingsBase {\n        \n        private static Preferences defaultInstance = ((Preferences)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Preferences())));\n        \n        public static Preferences Default {\n            get {\n                return defaultInstance;\n            }\n        }\n        \n        [global::System.Configuration.UserScopedSettingAttribute()]\n        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\n        [global::System.Configuration.DefaultSettingValueAttribute(\"\")]\n        public string ip_address {\n            get {\n                return ((string)(this[\"ip_address\"]));\n            }\n            set {\n                this[\"ip_address\"] = value;\n            }\n        }\n        \n        [global::System.Configuration.UserScopedSettingAttribute()]\n        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\n        [global::System.Configuration.DefaultSettingValueAttribute(\"True\")]\n        public bool att_enabled {\n            get {\n                return ((bool)(this[\"att_enabled\"]));\n            }\n            set {\n                this[\"att_enabled\"] = value;\n            }\n        }\n        \n        [global::System.Configuration.UserScopedSettingAttribute()]\n        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\n        [global::System.Configuration.DefaultSettingValueAttribute(\"True\")]\n        public bool pos_enabled {\n            get {\n                return ((bool)(this[\"pos_enabled\"]));\n            }\n            set {\n                this[\"pos_enabled\"] = value;\n            }\n        }\n        \n        [global::System.Configuration.UserScopedSettingAttribute()]\n        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\n        [global::System.Configuration.DefaultSettingValueAttribute(\"True\")]\n        public bool tfk_enabled {\n            get {\n                return ((bool)(this[\"tfk_enabled\"]));\n            }\n            set {\n                this[\"tfk_enabled\"] = value;\n            }\n        }\n        \n        [global::System.Configuration.UserScopedSettingAttribute()]\n        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\n        [global::System.Configuration.DefaultSettingValueAttribute(\"True\")]\n        public bool ip_detection_enabled {\n            get {\n                return ((bool)(this[\"ip_detection_enabled\"]));\n            }\n            set {\n                this[\"ip_detection_enabled\"] = value;\n            }\n        }\n\n        [global::System.Configuration.UserScopedSettingAttribute()]\n        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\n        [global::System.Configuration.DefaultSettingValueAttribute(\"True\")]\n        public bool auto_connect_enabled {\n            get {\n                return ((bool)(this[\"auto_connect_enabled\"]));\n            }\n            set {\n                this[\"auto_connect_enabled\"] = value;\n            }\n        }\n        \n        [global::System.Configuration.UserScopedSettingAttribute()]\n        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\n        [global::System.Configuration.DefaultSettingValueAttribute(\"6\")]\n        public uint att_freq {\n            get {\n                return ((uint)(this[\"att_freq\"]));\n            }\n            set {\n                this[\"att_freq\"] = value;\n            }\n        }\n        \n        [global::System.Configuration.UserScopedSettingAttribute()]\n        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\n        [global::System.Configuration.DefaultSettingValueAttribute(\"10\")]\n        public uint ip_hint_time {\n            get {\n                return ((uint)(this[\"ip_hint_time\"]));\n            }\n            set {\n                this[\"ip_hint_time\"] = value;\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "Preferences.settings",
    "content": "﻿<?xml version='1.0' encoding='utf-8'?>\n<SettingsFile xmlns=\"http://schemas.microsoft.com/VisualStudio/2004/01/settings\" CurrentProfile=\"(Default)\" GeneratedClassNamespace=\"fs2ff\" GeneratedClassName=\"Preferences\">\n  <Profiles />\n  <Settings>\n    <Setting Name=\"ip_address\" Type=\"System.String\" Scope=\"User\">\n      <Value Profile=\"(Default)\" />\n    </Setting>\n    <Setting Name=\"att_enabled\" Type=\"System.Boolean\" Scope=\"User\">\n      <Value Profile=\"(Default)\">True</Value>\n    </Setting>\n    <Setting Name=\"pos_enabled\" Type=\"System.Boolean\" Scope=\"User\">\n      <Value Profile=\"(Default)\">True</Value>\n    </Setting>\n    <Setting Name=\"tfk_enabled\" Type=\"System.Boolean\" Scope=\"User\">\n      <Value Profile=\"(Default)\">True</Value>\n    </Setting>\n    <Setting Name=\"ip_detection_enabled\" Type=\"System.Boolean\" Scope=\"User\">\n      <Value Profile=\"(Default)\">True</Value>\n    </Setting>\n    <Setting Name=\"att_freq\" Type=\"System.UInt32\" Scope=\"User\">\n      <Value Profile=\"(Default)\">6</Value>\n    </Setting>\n    <Setting Name=\"ip_hint_time\" Type=\"System.UInt32\" Scope=\"User\">\n      <Value Profile=\"(Default)\">10</Value>\n    </Setting>\n    <Setting Name=\"auto_connect_enabled\" Type=\"System.Boolean\" Scope=\"User\">\n      <Value Profile=\"(Default)\">True</Value>\n    </Setting>\n  </Settings>\n</SettingsFile>"
  },
  {
    "path": "README.md",
    "content": "# fs2ff (Flight Simulator to ForeFlight)\n\n## What is it?\n\nThis is a utility app that connects Microsoft Flight Simulator 2020 with the Electronic Flight Bag (EFB) app ForeFlight, sharing virtual GPS data from the former to the latter. This allows the use of ForeFlight as a navigational aid when simming. Much more cost-effective than flying an actual airplane!\n\n## How do I use it?\n\nSimple! Just follow these easy steps:\n1. Start Microsoft Flight Simulator. As soon as you get to the main menu, the game is ready to accept connections.\n1. While waiting for MSFS to start (it takes a while!), download fs2ff.exe from the [latest release](https://github.com/astenlund/fs2ff/releases/latest).\n1. Double-click the file.\n1. If you get a popup window that tells you that \"Windows protected your PC\", click More info -> Run anyway.\n1. In the fs2ff app, click the big Connect button. Unless anything goes wrong, you will now be connected to MSFS.\n1. To verify the connection, open ForeFlight on your iPad or iPhone and navigate to More -> Devices.\n1. Do not forget to activate Auto Center (upper right corner) in the map view in ForeFlight.\n1. Now go fly!\n\n__N.B.__ Since I have not bothered to create an installer for this app, you will just have to save it somewhere on your harddrive where you can find it again. Why not your desktop? ;)\n\n## Ok, but what does it actually do?\n\nThe app uses Microsoft's SimConnect SDK to continuously collect data about the player's own aircraft in the game, as well as other traffic around the player, and then broadcast these data so they can be picked up by ForeFlight. This requires that the ForeFlight device is connected to the same Wi-Fi network as the Flight Sim computer. Also, UDP port 49002 must not be blocked by any firewalls.\n\n## Does it work with other EFB apps?\n\n### SkyDemon\n\nYes! SkyDemon is compatible with X-Plane, which uses the same format. You will need to enable the \"X-Plane\" toggle in the \"Third Party Devices\" settings pane under the cogwheel in SkyDemon. Then, when you start flying, select \"Use X-Plane\".\n\n### Garmin Pilot\n\nYes! Go to \"Settings\" -> \"Flight Simulation\" and enable the \"Use Flight Simulator Data\" option.\n\n### Enroute Flight Navigation\n\nYes! Go to \"Settings\" -> \"Primary position data source\" and select \"Traffic data receiver\" as the main source. More information can be found in the [Enroute Flight Navigation Manual](https://akaflieg-freiburg.github.io/enrouteManual/02-tutorialBasic/07-simulator.html#connect-your-flight-simulator).\n\n### Other apps (not verified by me)\n\n- FlyQ EFB (thanks, @erayymz)\n- FltPlan GO (need to select XPlane as source of GPS data)\n\n## Does it work with other flight simulators?\n\n### X-Plane\n\nNo need for my app. X-Plane already has this broadcast capability built-in, see [this support page](https://foreflight.com/support/support-center/category/about-foreflight-mobile/204115525).\n\n### Prepar3D\n\nShould work straight out of the box for P3D 4.0 and up, so no need for my app. For older versions, use [FSUIPC](http://www.schiratti.com/dowson.html). See [this support page](https://foreflight.com/support/support-center/category/about-foreflight-mobile/204115345).\n\n### Other flight sims\n\nAs of now, no other flight simulators have been tested.\n\n## How do I build this?\n\n1. Download and install [.NET Core SDK](https://dotnet.microsoft.com/download) and [Visual Studio Community](https://visualstudio.microsoft.com/downloads/).\n1. Clone the repo or download and extract [a zip](https://github.com/astenlund/fs2ff/archive/master.zip).\n1. Install MSFS SDK (see instructions below).\n1. Navigate to the SDK on your hard drive and find the following two files:\n   - \"MSFS SDK\\SimConnect SDK\\lib\\SimConnect.dll\"\n   - \"MSFS SDK\\SimConnect SDK\\lib\\managed\\Microsoft.FlightSimulator.SimConnect.dll\"\n1. Create a folder called \"lib\" in the fs2ff folder (next to fs2ff.sln) and put the two dll:s therein.\n1. Open fs2ff.sln with Visual Studio.\n1. Build by pressing Ctrl-Shift-B.\n1. Or from command-line: `dotnet build`.\n1. To build a self-contained executable, run: `dotnet publish -c Release -r win-x64 /p:PublishSingleFile=true`.\n\n## Where do I get the MSFS SDK?\n\n1. Hop into Flight Simulator.\n1. Go to OPTIONS -> GENERAL -> DEVELOPERS and enable DEVELOPER MODE.\n1. You will now have a new menu at the top. Click Help -> SDK Installer.\n1. Let your browser download the installer and run it.\n1. You might get a \"Windows protected your PC\" popup. If so, click More info -> Run anyway.\n1. Go through the installation wizard and make sure that Core Components is selected.\n1. When finished, you will likely find the SDK installed under \"C:\\MSFS SDK\".\n\n## What's with the \"Windows protected your PC\" popup?\n\nThis is Microsoft telling you that the app has not been cryptographically signed. Software that you download from big corporations does not present this behaviour, because these companies typically purchase certificates from trusted Certificate Authorities and sign their binaries before shipping to customers. This is cumbersome and expensive and not in the scope of this open source project. The binaries that I have provided are for convenience. If you do not trust me (and why should you?), you are more than welcome to build from source yourself (see instructions above).\n\n## I have problems!\n\nIf you are experiencing any technical issues with the app (or if you see potential for other improvements), please open up an [issue](https://github.com/astenlund/fs2ff/issues), and I will be happy to take a look.\n"
  },
  {
    "path": "Resources.xaml",
    "content": "<ResourceDictionary xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\"\n                    xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\">\n    <ControlTemplate TargetType=\"TextBox\" x:Key=\"WatermarkTextBoxTemplate\">\n        <Grid>\n            <TextBox Text=\"{\n                    Binding Text, Mode=TwoWay,\n                    RelativeSource={RelativeSource TemplatedParent},\n                    UpdateSourceTrigger=PropertyChanged}\" />\n            <TextBlock\n                HorizontalAlignment=\"Left\"\n                VerticalAlignment=\"Center\"\n                Text=\"{Binding Tag, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}\"\n                Margin=\"10,0\"\n                Foreground=\"#FF808080\"\n                FontStyle=\"Italic\"\n                IsHitTestVisible=\"False\"\n                x:Name=\"Watermark\"\n                Visibility=\"Hidden\" />\n        </Grid>\n        <ControlTemplate.Triggers>\n            <MultiTrigger>\n                <Setter Property=\"Visibility\" TargetName=\"Watermark\" Value=\"Visible\" />\n                <MultiTrigger.Conditions>\n                    <Condition Property=\"Text\" Value=\"\" />\n                </MultiTrigger.Conditions>\n            </MultiTrigger>\n        </ControlTemplate.Triggers>\n    </ControlTemplate>\n</ResourceDictionary>\n"
  },
  {
    "path": "SimConnect/DEFINITION.cs",
    "content": "// ReSharper disable InconsistentNaming\n// ReSharper disable UnusedMember.Global\n\nnamespace fs2ff.SimConnect\n{\n    public enum DEFINITION : uint\n    {\n        Undefined,\n        Position,\n        Attitude,\n        Traffic\n    }\n}\n"
  },
  {
    "path": "SimConnect/EVENT.cs",
    "content": "// ReSharper disable InconsistentNaming\n// ReSharper disable UnusedMember.Global\n\nnamespace fs2ff.SimConnect\n{\n    public enum EVENT : uint\n    {\n        Undefined,\n        ObjectAdded,\n        SixHz\n    }\n}\n"
  },
  {
    "path": "SimConnect/ISimConnectMessageHandler.cs",
    "content": "﻿using System;\n\nnamespace fs2ff.SimConnect\n{\n    public interface ISimConnectMessageHandler : IDisposable\n    {\n        public void ReceiveFlightSimMessage();\n        public IntPtr WindowHandle { set; }\n    }\n}\n"
  },
  {
    "path": "SimConnect/REQUEST.cs",
    "content": "// ReSharper disable InconsistentNaming\n// ReSharper disable UnusedMember.Global\n\nnamespace fs2ff.SimConnect\n{\n    public enum REQUEST : uint\n    {\n        Undefined,\n        Position,\n        Attitude,\n        TrafficAircraft,\n        TrafficHelicopter,\n        TrafficObjectBase = 0x01000000\n    }\n}\n"
  },
  {
    "path": "SimConnect/SimConnectAdapter.cs",
    "content": "﻿// ReSharper disable InconsistentNaming\n\nusing System;\nusing System.Linq;\nusing System.Runtime.InteropServices;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing fs2ff.Models;\nusing Microsoft.FlightSimulator.SimConnect;\nusing SimConnectImpl = Microsoft.FlightSimulator.SimConnect.SimConnect;\n\nnamespace fs2ff.SimConnect\n{\n    public class SimConnectAdapter : IDisposable\n    {\n        private const string AppName = \"fs2ff\";\n        private const uint WM_USER_SIMCONNECT = 0x0402;\n\n        private Timer? _attitudeTimer;\n        private SimConnectImpl? _simConnect;\n\n        public event Func<Attitude, Task>? AttitudeReceived;\n        public event Func<Position, Task>? PositionReceived;\n        public event Action<bool>? StateChanged;\n        public event Func<Traffic, uint, Task>? TrafficReceived;\n\n        public bool Connected => _simConnect != null;\n\n        public void Connect(IntPtr hwnd, uint attitudeFrequency)\n        {\n            try\n            {\n                UnsubscribeEvents();\n\n                _simConnect?.Dispose();\n                _attitudeTimer?.Dispose();\n\n                _simConnect = new SimConnectImpl(AppName, hwnd, WM_USER_SIMCONNECT, null, 0);\n                _attitudeTimer = new Timer(RequestAttitudeData, null, 100, 1000 / attitudeFrequency);\n\n                SubscribeEvents();\n\n                StateChanged?.Invoke(false);\n            }\n            catch (COMException e)\n            {\n                Console.Error.WriteLine(\"Exception caught: \" + e);\n                StateChanged?.Invoke(true);\n            }\n        }\n\n        public void Disconnect() => DisconnectInternal(false);\n\n        public void Dispose() => DisconnectInternal(false);\n\n        public void ReceiveMessage()\n        {\n            try\n            {\n                _simConnect?.ReceiveMessage();\n            }\n            catch (COMException e)\n            {\n                Console.Error.WriteLine(\"Exception caught: \" + e);\n                DisconnectInternal(true);\n            }\n        }\n\n        public void SetAttitudeFrequency(uint frequency)\n        {\n            _attitudeTimer?.Change(0, 1000 / frequency);\n        }\n\n        private void AddToDataDefinition(DEFINITION defineId, string datumName, string? unitsName, SIMCONNECT_DATATYPE datumType = SIMCONNECT_DATATYPE.FLOAT64)\n        {\n            _simConnect?.AddToDataDefinition(defineId, datumName, unitsName, datumType, 0, SimConnectImpl.SIMCONNECT_UNUSED);\n        }\n\n        private void DisconnectInternal(bool failure)\n        {\n            UnsubscribeEvents();\n\n            _attitudeTimer?.Dispose();\n            _attitudeTimer = null;\n\n            _simConnect?.Dispose();\n            _simConnect = null;\n\n            StateChanged?.Invoke(failure);\n        }\n\n        private void RegisterAttitudeStruct()\n        {\n            AddToDataDefinition(DEFINITION.Attitude, \"PLANE PITCH DEGREES\", \"Degrees\");\n            AddToDataDefinition(DEFINITION.Attitude, \"PLANE BANK DEGREES\", \"Degrees\");\n            AddToDataDefinition(DEFINITION.Attitude, \"PLANE HEADING DEGREES TRUE\", \"Degrees\");\n\n            _simConnect?.RegisterDataDefineStruct<Attitude>(DEFINITION.Attitude);\n        }\n\n        private void RegisterPositionStruct()\n        {\n            AddToDataDefinition(DEFINITION.Position, \"PLANE LATITUDE\", \"Degrees\");\n            AddToDataDefinition(DEFINITION.Position, \"PLANE LONGITUDE\", \"Degrees\");\n            AddToDataDefinition(DEFINITION.Position, \"PLANE ALTITUDE\", \"Meters\");\n            AddToDataDefinition(DEFINITION.Position, \"GPS GROUND TRUE TRACK\", \"Degrees\");\n            AddToDataDefinition(DEFINITION.Position, \"GPS GROUND SPEED\", \"Meters per second\");\n\n            _simConnect?.RegisterDataDefineStruct<Position>(DEFINITION.Position);\n        }\n\n        private void RegisterTrafficStruct()\n        {\n            AddToDataDefinition(DEFINITION.Traffic, \"PLANE LATITUDE\", \"Degrees\");\n            AddToDataDefinition(DEFINITION.Traffic, \"PLANE LONGITUDE\", \"Degrees\");\n            AddToDataDefinition(DEFINITION.Traffic, \"PLANE ALTITUDE\", \"Feet\");\n            AddToDataDefinition(DEFINITION.Traffic, \"VELOCITY WORLD Y\", \"Feet per minute\");\n            AddToDataDefinition(DEFINITION.Traffic, \"SIM ON GROUND\", \"Bool\", SIMCONNECT_DATATYPE.INT32);\n            AddToDataDefinition(DEFINITION.Traffic, \"PLANE HEADING DEGREES TRUE\", \"Degrees\");\n            AddToDataDefinition(DEFINITION.Traffic, \"GROUND VELOCITY\", \"Knots\");\n            AddToDataDefinition(DEFINITION.Traffic, \"ATC ID\", null, SIMCONNECT_DATATYPE.STRING64);\n            AddToDataDefinition(DEFINITION.Traffic, \"ATC AIRLINE\", null, SIMCONNECT_DATATYPE.STRING64);\n            AddToDataDefinition(DEFINITION.Traffic, \"ATC FLIGHT NUMBER\", null, SIMCONNECT_DATATYPE.STRING8);\n\n            _simConnect?.RegisterDataDefineStruct<Traffic>(DEFINITION.Traffic);\n        }\n\n        private void RequestAttitudeData(object? _)\n        {\n            try\n            {\n                _simConnect?.RequestDataOnSimObject(\n                    REQUEST.Attitude, DEFINITION.Attitude,\n                    SimConnectImpl.SIMCONNECT_OBJECT_ID_USER,\n                    SIMCONNECT_PERIOD.ONCE,\n                    SIMCONNECT_DATA_REQUEST_FLAG.DEFAULT,\n                    0, 0, 0);\n            }\n            catch (COMException e)\n            {\n                Console.Error.WriteLine(\"Exception caught: \" + e);\n            }\n        }\n\n        private void SimConnect_OnRecvEventObjectAddremove(SimConnectImpl sender, SIMCONNECT_RECV_EVENT_OBJECT_ADDREMOVE data)\n        {\n            if (data.uEventID == (uint) EVENT.ObjectAdded &&\n                (data.eObjType == SIMCONNECT_SIMOBJECT_TYPE.AIRCRAFT ||\n                 data.eObjType == SIMCONNECT_SIMOBJECT_TYPE.HELICOPTER) &&\n                data.dwData != SimConnectImpl.SIMCONNECT_OBJECT_ID_USER)\n            {\n                _simConnect?.RequestDataOnSimObject(\n                    REQUEST.TrafficObjectBase + data.dwData,\n                    DEFINITION.Traffic, data.dwData,\n                    SIMCONNECT_PERIOD.SECOND,\n                    SIMCONNECT_DATA_REQUEST_FLAG.DEFAULT,\n                    0, 0, 0);\n            }\n        }\n\n        private void SimConnect_OnRecvException(SimConnectImpl sender, SIMCONNECT_RECV_EXCEPTION data)\n        {\n            Console.Error.WriteLine(\"Exception caught: \" + data.dwException);\n            DisconnectInternal(true);\n        }\n\n        private void SimConnect_OnRecvOpen(SimConnectImpl sender, SIMCONNECT_RECV data)\n        {\n            RegisterPositionStruct();\n            RegisterAttitudeStruct();\n            RegisterTrafficStruct();\n\n            _simConnect?.RequestDataOnSimObject(\n                REQUEST.Position, DEFINITION.Position,\n                SimConnectImpl.SIMCONNECT_OBJECT_ID_USER,\n                SIMCONNECT_PERIOD.SECOND,\n                SIMCONNECT_DATA_REQUEST_FLAG.DEFAULT,\n                0, 0, 0);\n\n            _simConnect?.RequestDataOnSimObjectType(REQUEST.TrafficAircraft, DEFINITION.Traffic, 200000, SIMCONNECT_SIMOBJECT_TYPE.AIRCRAFT);\n            _simConnect?.RequestDataOnSimObjectType(REQUEST.TrafficHelicopter, DEFINITION.Traffic, 200000, SIMCONNECT_SIMOBJECT_TYPE.HELICOPTER);\n\n            _simConnect?.SubscribeToSystemEvent(EVENT.ObjectAdded, \"ObjectAdded\");\n            _simConnect?.SubscribeToSystemEvent(EVENT.SixHz, \"6Hz\");\n        }\n\n        private void SimConnect_OnRecvQuit(SimConnectImpl sender, SIMCONNECT_RECV data)\n        {\n            DisconnectInternal(false);\n        }\n\n        private async void SimConnect_OnRecvSimobjectData(SimConnectImpl sender, SIMCONNECT_RECV_SIMOBJECT_DATA data)\n        {\n            if (data.dwRequestID == (uint) REQUEST.Position &&\n                data.dwDefineID == (uint) DEFINITION.Position &&\n                data.dwData?.FirstOrDefault() is Position pos)\n            {\n                await PositionReceived.RaiseAsync(pos).ConfigureAwait(false);\n            }\n\n            if (data.dwRequestID == (uint) REQUEST.Attitude &&\n                data.dwDefineID == (uint) DEFINITION.Attitude &&\n                data.dwData?.FirstOrDefault() is Attitude att)\n            {\n                await AttitudeReceived.RaiseAsync(att).ConfigureAwait(false);\n            }\n\n            if (data.dwRequestID == (uint) REQUEST.TrafficObjectBase + data.dwObjectID &&\n                data.dwDefineID == (uint) DEFINITION.Traffic &&\n                data.dwObjectID != SimConnectImpl.SIMCONNECT_OBJECT_ID_USER &&\n                data.dwData?.FirstOrDefault() is Traffic tfk)\n            {\n                await TrafficReceived.RaiseAsync(tfk, data.dwObjectID).ConfigureAwait(false);\n            }\n        }\n\n        private void SimConnect_OnRecvSimobjectDataBytype(SimConnectImpl sender, SIMCONNECT_RECV_SIMOBJECT_DATA_BYTYPE data)\n        {\n            if ((data.dwRequestID == (uint) REQUEST.TrafficAircraft ||\n                 data.dwRequestID == (uint) REQUEST.TrafficHelicopter) &&\n                data.dwDefineID == (uint) DEFINITION.Traffic &&\n                data.dwObjectID != SimConnectImpl.SIMCONNECT_OBJECT_ID_USER)\n            {\n                _simConnect?.RequestDataOnSimObject(\n                    REQUEST.TrafficObjectBase + data.dwObjectID,\n                    DEFINITION.Traffic, data.dwObjectID,\n                    SIMCONNECT_PERIOD.SECOND,\n                    SIMCONNECT_DATA_REQUEST_FLAG.DEFAULT,\n                    0, 0, 0);\n            }\n        }\n\n        private void SubscribeEvents()\n        {\n            if (_simConnect != null)\n            {\n                _simConnect.OnRecvOpen += SimConnect_OnRecvOpen;\n                _simConnect.OnRecvQuit += SimConnect_OnRecvQuit;\n                _simConnect.OnRecvException += SimConnect_OnRecvException;\n                _simConnect.OnRecvSimobjectData += SimConnect_OnRecvSimobjectData;\n                _simConnect.OnRecvSimobjectDataBytype += SimConnect_OnRecvSimobjectDataBytype;\n                _simConnect.OnRecvEventObjectAddremove += SimConnect_OnRecvEventObjectAddremove;\n            }\n        }\n\n        private void UnsubscribeEvents()\n        {\n            if (_simConnect != null)\n            {\n                _simConnect.OnRecvEventObjectAddremove -= SimConnect_OnRecvEventObjectAddremove;\n                _simConnect.OnRecvSimobjectDataBytype -= SimConnect_OnRecvSimobjectDataBytype;\n                _simConnect.OnRecvSimobjectData -= SimConnect_OnRecvSimobjectData;\n                _simConnect.OnRecvException -= SimConnect_OnRecvException;\n                _simConnect.OnRecvQuit -= SimConnect_OnRecvQuit;\n                _simConnect.OnRecvOpen -= SimConnect_OnRecvOpen;\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "UpdateChecker.cs",
    "content": "using System;\nusing System.Net.Http;\nusing System.Threading.Tasks;\n\nnamespace fs2ff\n{\n    public static class UpdateChecker\n    {\n        public static async Task<UpdateInformation?> Check()\n        {\n            try\n            {\n                using var handler = new HttpClientHandler { AllowAutoRedirect = false };\n                using var client = new HttpClient(handler);\n\n                var response = await client.GetAsync(new Uri(\"https://github.com/astenlund/fs2ff/releases/latest\")).ConfigureAwait(false);\n                var location = response.Headers.Location;\n                var versionStr = location?.Segments[^1];\n\n                return (Version.TryParse(versionStr?.TrimStart('v'), out var version) && version > App.AssemblyVersion)\n                    ? new UpdateInformation(version, location!)\n                    : null;\n            }\n            catch (Exception e)\n            {\n                await Console.Error.WriteLineAsync(\"Exception caught: \" + e);\n                return default;\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "UpdateInformation.cs",
    "content": "// ReSharper disable MemberCanBePrivate.Global\n// ReSharper disable UnusedAutoPropertyAccessor.Global\n\nusing System;\n\nnamespace fs2ff\n{\n    public class UpdateInformation\n    {\n        public UpdateInformation(Version version, Uri downloadLink)\n        {\n            Version = version;\n            DownloadLink = downloadLink;\n        }\n\n        public Version Version { get; }\n\n        public Uri DownloadLink { get; }\n    }\n}\n"
  },
  {
    "path": "ViewModelLocator.cs",
    "content": "﻿namespace fs2ff\n{\n    public class ViewModelLocator\n    {\n        public static MainViewModel Main => App.GetRequiredService<MainViewModel>();\n    }\n}\n"
  },
  {
    "path": "fs2ff.csproj",
    "content": "﻿<Project Sdk=\"Microsoft.NET.Sdk.WindowsDesktop\">\n\n  <PropertyGroup>\n    <OutputType>WinExe</OutputType>\n    <TargetFramework>netcoreapp3.1</TargetFramework>\n    <RuntimeIdentifier>win-x64</RuntimeIdentifier>\n    <ApplicationIcon>img\\icon.ico</ApplicationIcon>\n    <UseWPF>true</UseWPF>\n    <LangVersion>8</LangVersion>\n    <Nullable>enable</Nullable>\n    <Version>0.0.0-dev</Version>\n  </PropertyGroup>\n\n  <ItemGroup>\n    <Reference Include=\"Microsoft.FlightSimulator.SimConnect, Version=11.0.62651.3, Culture=neutral, PublicKeyToken=baf445ffb3a06b5c\">\n      <HintPath>lib\\Microsoft.FlightSimulator.SimConnect.dll</HintPath>\n    </Reference>\n  </ItemGroup>\n\n  <ItemGroup>\n    <ContentWithTargetPath Include=\"lib\\concrt140.dll\">\n      <CopyToOutputDirectory>Always</CopyToOutputDirectory>\n      <TargetPath>concrt140.dll</TargetPath>\n    </ContentWithTargetPath>\n    <ContentWithTargetPath Include=\"lib\\msvcp140.dll\">\n      <CopyToOutputDirectory>Always</CopyToOutputDirectory>\n      <TargetPath>msvcp140.dll</TargetPath>\n    </ContentWithTargetPath>\n    <ContentWithTargetPath Include=\"lib\\SimConnect.dll\">\n      <CopyToOutputDirectory>Always</CopyToOutputDirectory>\n      <TargetPath>SimConnect.dll</TargetPath>\n    </ContentWithTargetPath>\n    <ContentWithTargetPath Include=\"lib\\vcruntime140.dll\">\n      <CopyToOutputDirectory>Always</CopyToOutputDirectory>\n      <TargetPath>vcruntime140.dll</TargetPath>\n    </ContentWithTargetPath>\n    <ContentWithTargetPath Include=\"lib\\vcruntime140_1.dll\">\n      <CopyToOutputDirectory>Always</CopyToOutputDirectory>\n      <TargetPath>vcruntime140_1.dll</TargetPath>\n    </ContentWithTargetPath>\n  </ItemGroup>\n\n  <ItemGroup>\n    <PackageReference Include=\"Fody\" Version=\"6.6.0\">\n      <PrivateAssets>all</PrivateAssets>\n      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>\n    </PackageReference>\n    <PackageReference Include=\"Microsoft.Extensions.Hosting\" Version=\"5.0.0\" />\n    <PackageReference Include=\"Microsoft.Xaml.Behaviors.Wpf\" Version=\"1.1.37\" />\n    <PackageReference Include=\"ModernWpfUI\" Version=\"0.9.4\" />\n    <PackageReference Include=\"PropertyChanged.Fody\" Version=\"3.4.0\">\n      <PrivateAssets>all</PrivateAssets>\n    </PackageReference>\n  </ItemGroup>\n\n  <ItemGroup>\n    <None Remove=\"img\\icon.ico\" />\n    <Resource Include=\"img\\icon.ico\">\n      <CopyToOutputDirectory>Always</CopyToOutputDirectory>\n    </Resource>\n  </ItemGroup>\n\n  <ItemGroup>\n    <Compile Update=\"Preferences.Designer.cs\">\n      <DesignTimeSharedInput>True</DesignTimeSharedInput>\n      <AutoGen>True</AutoGen>\n      <DependentUpon>Preferences.settings</DependentUpon>\n    </Compile>\n  </ItemGroup>\n\n  <ItemGroup>\n    <None Update=\"Preferences.settings\">\n      <Generator>SettingsSingleFileGenerator</Generator>\n      <LastGenOutput>Preferences.Designer.cs</LastGenOutput>\n    </None>\n  </ItemGroup>\n\n</Project>\n"
  },
  {
    "path": "fs2ff.sln",
    "content": "﻿\nMicrosoft Visual Studio Solution File, Format Version 12.00\n# Visual Studio 15\nVisualStudioVersion = 15.0.26124.0\nMinimumVisualStudioVersion = 15.0.26124.0\nProject(\"{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}\") = \"fs2ff\", \"fs2ff.csproj\", \"{95A935C1-D0D3-43E6-BA38-CB19BD196F5C}\"\nEndProject\nGlobal\n\tGlobalSection(SolutionProperties) = preSolution\n\t\tHideSolutionNode = FALSE\n\tEndGlobalSection\n\tGlobalSection(SolutionConfigurationPlatforms) = preSolution\n\t\tDebug|Any CPU = Debug|Any CPU\n\t\tDebug|x64 = Debug|x64\n\t\tDebug|x86 = Debug|x86\n\t\tRelease|Any CPU = Release|Any CPU\n\t\tRelease|x64 = Release|x64\n\t\tRelease|x86 = Release|x86\n\tEndGlobalSection\n\tGlobalSection(ProjectConfigurationPlatforms) = postSolution\n\t\t{95A935C1-D0D3-43E6-BA38-CB19BD196F5C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU\n\t\t{95A935C1-D0D3-43E6-BA38-CB19BD196F5C}.Debug|Any CPU.Build.0 = Debug|Any CPU\n\t\t{95A935C1-D0D3-43E6-BA38-CB19BD196F5C}.Debug|x64.ActiveCfg = Debug|Any CPU\n\t\t{95A935C1-D0D3-43E6-BA38-CB19BD196F5C}.Debug|x64.Build.0 = Debug|Any CPU\n\t\t{95A935C1-D0D3-43E6-BA38-CB19BD196F5C}.Debug|x86.ActiveCfg = Debug|Any CPU\n\t\t{95A935C1-D0D3-43E6-BA38-CB19BD196F5C}.Debug|x86.Build.0 = Debug|Any CPU\n\t\t{95A935C1-D0D3-43E6-BA38-CB19BD196F5C}.Release|Any CPU.ActiveCfg = Release|Any CPU\n\t\t{95A935C1-D0D3-43E6-BA38-CB19BD196F5C}.Release|Any CPU.Build.0 = Release|Any CPU\n\t\t{95A935C1-D0D3-43E6-BA38-CB19BD196F5C}.Release|x64.ActiveCfg = Release|Any CPU\n\t\t{95A935C1-D0D3-43E6-BA38-CB19BD196F5C}.Release|x64.Build.0 = Release|Any CPU\n\t\t{95A935C1-D0D3-43E6-BA38-CB19BD196F5C}.Release|x86.ActiveCfg = Release|Any CPU\n\t\t{95A935C1-D0D3-43E6-BA38-CB19BD196F5C}.Release|x86.Build.0 = Release|Any CPU\n\tEndGlobalSection\nEndGlobal\n"
  },
  {
    "path": "global.json",
    "content": "{\n  \"sdk\": {\n    \"version\": \"3.1.100\",\n    \"rollForward\": \"latestFeature\"\n  }\n}\n"
  },
  {
    "path": "publish.ps1",
    "content": "param (\n    [ValidateSet('Debug','Release')]\n    [string]$Configuration = 'Release',\n    [ValidateSet('win-x64','win10-x64')]\n    [string]$Runtime = 'win-x64',\n    [Parameter(Mandatory)]\n    [string]$Version,\n    [ValidateSet('quiet','minimal','normal','detailed','diagnostic')]\n    [string]$Verbosity = \"minimal\",\n    [switch]$UseR2R\n)\n\n$PublishDir = \"publish\"\n\nif (Test-Path $PublishDir) { Remove-Item $PublishDir -Recurse -Verbose }\n\ndotnet restore\n\ndotnet publish `\n    -o $PublishDir `\n    -r $Runtime `\n    -c $Configuration `\n    -v $Verbosity `\n    /p:DebugType=none `\n    /p:DebugSymbols=false `\n    /p:SelfContained=true `\n    /p:PublishSingleFile=true `\n    /P:PublishReadyToRun=$UseR2R `\n    /p:PublishReadyToRunShowWarnings=$UseR2R `\n    /p:Version=$Version\n\nGet-Item \"$PublishDir\\fs2ff.exe\" |\n    Select-Object Name,\n        @{ Name = 'Version'; Expression = { $_.VersionInfo.ProductVersion }},\n        @{ Name = 'Size'; Expression = { \"{0:f0} MB`r`n\" -f ($_.Length / 1MB) }} |\n    Format-List\n"
  }
]