Skip to content

Commit 5d17538

Browse files
committed
Split off from RT.Util
1 parent 4e5dcd8 commit 5d17538

8 files changed

Lines changed: 514 additions & 3 deletions

File tree

.editorconfig

Lines changed: 306 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,306 @@
1+
root = true
2+
3+
# All files
4+
[*]
5+
indent_size = 4
6+
indent_style = space
7+
tab_width = 4
8+
9+
# ReSharper properties
10+
resharper_blank_lines_after_block_statements = 0
11+
resharper_blank_lines_around_auto_property = 0
12+
resharper_blank_lines_around_local_method = 0
13+
resharper_csharp_blank_lines_around_field = 0
14+
resharper_csharp_wrap_lines = false
15+
resharper_keep_existing_arrangement = true
16+
17+
# Code files
18+
[*.{cs,csx,json}]
19+
indent_size = 4
20+
end_of_line = crlf
21+
insert_final_newline = true
22+
charset = utf-8-bom
23+
24+
[*.csproj]
25+
indent_size = 2
26+
27+
#### .NET Coding Conventions ####
28+
[*.cs]
29+
# Organize usings
30+
dotnet_separate_import_directive_groups = false
31+
dotnet_sort_system_directives_first = true
32+
file_header_template =
33+
34+
# this. and Me. preferences
35+
dotnet_style_qualification_for_event = false
36+
dotnet_style_qualification_for_field = false
37+
dotnet_style_qualification_for_method = false
38+
dotnet_style_qualification_for_property = false
39+
40+
# Language keywords vs BCL types preferences
41+
dotnet_style_predefined_type_for_locals_parameters_members = true:warning
42+
dotnet_style_predefined_type_for_member_access = true:warning
43+
44+
# Parentheses preferences
45+
dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity
46+
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity
47+
dotnet_style_parentheses_in_other_operators = never_if_unnecessary
48+
dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity
49+
50+
# Modifier preferences
51+
dotnet_style_require_accessibility_modifiers = for_non_interface_members
52+
53+
# Expression-level preferences
54+
dotnet_style_coalesce_expression = true
55+
dotnet_style_collection_initializer = true
56+
dotnet_style_explicit_tuple_names = true
57+
dotnet_style_namespace_match_folder = true
58+
dotnet_style_null_propagation = true
59+
dotnet_style_object_initializer = true
60+
dotnet_style_operator_placement_when_wrapping = beginning_of_line
61+
dotnet_style_prefer_auto_properties = true
62+
dotnet_style_prefer_compound_assignment = true
63+
dotnet_style_prefer_conditional_expression_over_assignment = true
64+
dotnet_style_prefer_conditional_expression_over_return = true
65+
dotnet_style_prefer_inferred_anonymous_type_member_names = true
66+
dotnet_style_prefer_inferred_tuple_names = true
67+
dotnet_style_prefer_is_null_check_over_reference_equality_method = true
68+
dotnet_style_prefer_simplified_boolean_expressions = true
69+
dotnet_style_prefer_simplified_interpolation = true
70+
71+
# Field preferences
72+
dotnet_style_readonly_field = false
73+
74+
# Parameter preferences
75+
dotnet_code_quality_unused_parameters = all
76+
77+
# Suppression preferences
78+
dotnet_remove_unnecessary_suppression_exclusions = none
79+
80+
# New line preferences
81+
dotnet_style_allow_multiple_blank_lines_experimental = true
82+
dotnet_style_allow_statement_immediately_after_block_experimental = true
83+
84+
#### C# Coding Conventions ####
85+
86+
# var preferences
87+
csharp_style_var_elsewhere = false
88+
csharp_style_var_for_built_in_types = false
89+
csharp_style_var_when_type_is_apparent = false
90+
91+
# Expression-bodied members
92+
csharp_style_expression_bodied_accessors = true
93+
csharp_style_expression_bodied_constructors = false
94+
csharp_style_expression_bodied_indexers = true
95+
csharp_style_expression_bodied_lambdas = true
96+
csharp_style_expression_bodied_local_functions = false
97+
csharp_style_expression_bodied_methods = false
98+
csharp_style_expression_bodied_operators = false
99+
csharp_style_expression_bodied_properties = true
100+
101+
# Pattern matching preferences
102+
csharp_style_pattern_matching_over_as_with_null_check = true
103+
csharp_style_pattern_matching_over_is_with_cast_check = true
104+
csharp_style_prefer_not_pattern = true
105+
csharp_style_prefer_pattern_matching = true
106+
csharp_style_prefer_switch_expression = true
107+
108+
# Null-checking preferences
109+
csharp_style_conditional_delegate_call = true
110+
111+
# Modifier preferences
112+
csharp_prefer_static_local_function = true
113+
csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async
114+
115+
# Code-block preferences
116+
csharp_prefer_braces = true
117+
csharp_prefer_simple_using_statement = true
118+
csharp_style_namespace_declarations = file_scoped:suggestion
119+
120+
# Expression-level preferences
121+
csharp_prefer_simple_default_expression = true
122+
csharp_style_deconstructed_variable_declaration = true
123+
csharp_style_implicit_object_creation_when_type_is_apparent = true
124+
csharp_style_inlined_variable_declaration = true
125+
csharp_style_pattern_local_over_anonymous_function = true
126+
csharp_style_prefer_index_operator = true
127+
csharp_style_prefer_null_check_over_type_check = true
128+
csharp_style_prefer_range_operator = true
129+
csharp_style_throw_expression = true
130+
csharp_style_unused_value_assignment_preference = discard_variable
131+
csharp_style_unused_value_expression_statement_preference = discard_variable
132+
133+
# 'using' directive preferences
134+
csharp_using_directive_placement = outside_namespace
135+
136+
# New line preferences
137+
csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = true
138+
csharp_style_allow_blank_lines_between_consecutive_braces_experimental = true
139+
csharp_style_allow_embedded_statements_on_same_line_experimental = true
140+
141+
#### C# Formatting Rules ####
142+
143+
# New line preferences
144+
csharp_new_line_before_catch = true
145+
csharp_new_line_before_else = true
146+
csharp_new_line_before_finally = true
147+
csharp_new_line_before_members_in_anonymous_types = true
148+
csharp_new_line_before_members_in_object_initializers = false
149+
csharp_new_line_before_open_brace = all
150+
csharp_new_line_between_query_expression_clauses = true
151+
152+
# Indentation preferences
153+
csharp_indent_block_contents = true
154+
csharp_indent_braces = false
155+
csharp_indent_case_contents = true
156+
csharp_indent_case_contents_when_block = true
157+
csharp_indent_labels = no_change
158+
csharp_indent_switch_labels = true
159+
csharp_indent_nested_for_stmt = true
160+
csharp_indent_nested_foreach_stmt = true
161+
162+
# Space preferences
163+
csharp_space_after_cast = true
164+
csharp_space_after_colon_in_inheritance_clause = true
165+
csharp_space_after_comma = true
166+
csharp_space_after_dot = false
167+
csharp_space_after_keywords_in_control_flow_statements = true
168+
csharp_space_after_semicolon_in_for_statement = true
169+
csharp_space_around_binary_operators = before_and_after
170+
csharp_space_around_declaration_statements = false
171+
csharp_space_before_colon_in_inheritance_clause = true
172+
csharp_space_before_comma = false
173+
csharp_space_before_dot = false
174+
csharp_space_before_open_square_brackets = false
175+
csharp_space_before_semicolon_in_for_statement = false
176+
csharp_space_between_empty_square_brackets = false
177+
csharp_space_between_method_call_empty_parameter_list_parentheses = false
178+
csharp_space_between_method_call_name_and_opening_parenthesis = false
179+
csharp_space_between_method_call_parameter_list_parentheses = false
180+
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
181+
csharp_space_between_method_declaration_name_and_open_parenthesis = false
182+
csharp_space_between_method_declaration_parameter_list_parentheses = false
183+
csharp_space_between_parentheses = false
184+
csharp_space_between_square_brackets = false
185+
186+
# Wrapping preferences
187+
csharp_preserve_single_line_blocks = true
188+
csharp_preserve_single_line_statements = true
189+
190+
#### Naming styles ####
191+
192+
# Naming rules
193+
194+
dotnet_naming_rule.interface_should_be_begins_with_i.severity = suggestion
195+
dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface
196+
dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i
197+
198+
dotnet_naming_rule.types_should_be_pascal_case.severity = suggestion
199+
dotnet_naming_rule.types_should_be_pascal_case.symbols = types
200+
dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case
201+
202+
dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = suggestion
203+
dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members
204+
dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case
205+
206+
dotnet_naming_rule.private_method_should_be_camel_case.severity = suggestion
207+
dotnet_naming_rule.private_method_should_be_camel_case.symbols = private_method
208+
dotnet_naming_rule.private_method_should_be_camel_case.style = camel_case
209+
210+
dotnet_naming_rule.private_or_internal_field_should_be_begins_with__.severity = suggestion
211+
dotnet_naming_rule.private_or_internal_field_should_be_begins_with__.symbols = private_or_internal_field
212+
dotnet_naming_rule.private_or_internal_field_should_be_begins_with__.style = begins_with__
213+
214+
dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = suggestion
215+
dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols = constant_fields
216+
dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case
217+
218+
# Symbol specifications
219+
220+
dotnet_naming_symbols.interface.applicable_kinds = interface
221+
dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
222+
dotnet_naming_symbols.interface.required_modifiers =
223+
224+
dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum
225+
dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
226+
dotnet_naming_symbols.types.required_modifiers =
227+
228+
dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method
229+
dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
230+
dotnet_naming_symbols.non_field_members.required_modifiers =
231+
232+
dotnet_naming_symbols.private_method.applicable_kinds = method
233+
dotnet_naming_symbols.private_method.applicable_accessibilities = private
234+
dotnet_naming_symbols.private_method.required_modifiers =
235+
236+
dotnet_naming_symbols.private_or_internal_field.applicable_kinds = field
237+
dotnet_naming_symbols.private_or_internal_field.applicable_accessibilities = internal, private
238+
dotnet_naming_symbols.private_or_internal_field.required_modifiers =
239+
240+
dotnet_naming_symbols.constant_fields.applicable_kinds = field
241+
dotnet_naming_symbols.constant_fields.applicable_accessibilities = *
242+
dotnet_naming_symbols.constant_fields.required_modifiers = const
243+
244+
# Naming styles
245+
246+
dotnet_naming_style.pascal_case.required_prefix =
247+
dotnet_naming_style.pascal_case.required_suffix =
248+
dotnet_naming_style.pascal_case.word_separator =
249+
dotnet_naming_style.pascal_case.capitalization = pascal_case
250+
251+
dotnet_naming_style.begins_with_i.required_prefix = I
252+
dotnet_naming_style.begins_with_i.required_suffix =
253+
dotnet_naming_style.begins_with_i.word_separator =
254+
dotnet_naming_style.begins_with_i.capitalization = pascal_case
255+
256+
dotnet_naming_style.camel_case.required_prefix =
257+
dotnet_naming_style.camel_case.required_suffix =
258+
dotnet_naming_style.camel_case.word_separator =
259+
dotnet_naming_style.camel_case.capitalization = camel_case
260+
261+
dotnet_naming_style.begins_with__.required_prefix = _
262+
dotnet_naming_style.begins_with__.required_suffix =
263+
dotnet_naming_style.begins_with__.word_separator =
264+
dotnet_naming_style.begins_with__.capitalization = camel_case
265+
266+
#### Warning and error overrides ####
267+
268+
# CS0252: Possible unintended reference comparison; left hand side needs cast
269+
dotnet_diagnostic.cs0252.severity = error
270+
271+
# CS0253: Possible unintended reference comparison; right hand side needs cast
272+
dotnet_diagnostic.cs0253.severity = error
273+
274+
# CS8073: The result of the expression is always the same since a value of this type is never equal to 'null'
275+
dotnet_diagnostic.cs8073.severity = error
276+
277+
# IL3000: 'System.Reflection.Assembly.Location' always returns an empty string for assemblies embedded in a single-file app
278+
dotnet_diagnostic.il3000.severity = error
279+
280+
# CA1837: Use 'Environment.ProcessId'
281+
dotnet_diagnostic.ca1837.severity = warning
282+
283+
# CA1825: Avoid zero-length array allocations
284+
dotnet_diagnostic.ca1825.severity = none
285+
286+
# IDE0044: Add readonly modifier
287+
dotnet_diagnostic.ide0044.severity = none
288+
289+
# IDE0042: Deconstruct variable declaration
290+
dotnet_diagnostic.ide0042.severity = none
291+
292+
# CS1998: Async method lacks 'await' operators and will run synchronously
293+
dotnet_diagnostic.cs1998.severity = none
294+
295+
# CS8981: The type name 'info' only contains lower-cased ascii characters - we'll fix it if that happens
296+
dotnet_diagnostic.cs8981.severity = none
297+
298+
# Rider: Possible 'null' assignment to non-nullable entity (triggers even in nullable:disable contexts)
299+
resharper_assign_null_to_not_null_attribute_highlighting = none
300+
301+
# Rider: Possible multiple enumeration (it's a valid thing to do...)
302+
resharper_possible_multiple_enumeration_highlighting = none
303+
304+
# Rider: Member can be made private (it's a public member in a library, stop bugging me!!!)
305+
resharper_member_can_be_private_global_highlighting = none
306+
resharper_member_can_be_private_local_highlighting = none

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Builds
2+
.vs

Directory.Build.props

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<Project>
2+
<PropertyGroup>
3+
<!-- All normal build outputs are dumped into a single output directory. There is no per-project split.
4+
This won't work for every project but it works for this one. -->
5+
<!-- Intermediate files are placed into per-project subdirectories -->
6+
7+
<BaseOutputPath>$(MSBuildThisFileDirectory)Builds\</BaseOutputPath>
8+
<BaseIntermediateOutputPath>$(BaseOutputPath)obj\$(MSBuildProjectName)\</BaseIntermediateOutputPath>
9+
10+
<CustomSuffix>-$(TargetFramework)$(RuntimeIdentifier)</CustomSuffix>
11+
<CustomSuffix Condition="'$(CustomSuffix)'=='-'"></CustomSuffix>
12+
<OutputPath>$(BaseOutputPath)$(Configuration)$(CustomSuffix)\</OutputPath>
13+
<PublishDir>$(BaseOutputPath)$(Configuration)$(CustomSuffix)-publish\</PublishDir>
14+
<IntermediateOutputPath>$(BaseIntermediateOutputPath)$(Configuration)$(CustomSuffix)\</IntermediateOutputPath>
15+
16+
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
17+
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
18+
</PropertyGroup>
19+
</Project>

RT.Keyboard.sln

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
Microsoft Visual Studio Solution File, Format Version 12.00
2+
# Visual Studio Version 17
3+
VisualStudioVersion = 17.8.34330.188
4+
MinimumVisualStudioVersion = 10.0.40219.1
5+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RT.Keyboard", "Src\RT.Keyboard.csproj", "{4C4D7C5E-B27C-4428-B3F2-A34A58DDE20C}"
6+
EndProject
7+
Global
8+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
9+
Debug|Any CPU = Debug|Any CPU
10+
Release|Any CPU = Release|Any CPU
11+
EndGlobalSection
12+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
13+
{4C4D7C5E-B27C-4428-B3F2-A34A58DDE20C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
14+
{4C4D7C5E-B27C-4428-B3F2-A34A58DDE20C}.Debug|Any CPU.Build.0 = Debug|Any CPU
15+
{4C4D7C5E-B27C-4428-B3F2-A34A58DDE20C}.Release|Any CPU.ActiveCfg = Release|Any CPU
16+
{4C4D7C5E-B27C-4428-B3F2-A34A58DDE20C}.Release|Any CPU.Build.0 = Release|Any CPU
17+
EndGlobalSection
18+
GlobalSection(SolutionProperties) = preSolution
19+
HideSolutionNode = FALSE
20+
EndGlobalSection
21+
GlobalSection(ExtensibilityGlobals) = postSolution
22+
SolutionGuid = {68DAEDDF-02A0-4831-8894-E35CF959461F}
23+
EndGlobalSection
24+
EndGlobal

Src/GlobalKeyboardListener.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using System.Runtime.InteropServices;
33
using Timer = System.Windows.Forms.Timer;
44

5-
namespace RT.Util;
5+
namespace RT.Keyboard;
66

77
/// <summary>Manages a global low-level keyboard hook.</summary>
88
public sealed class GlobalKeyboardListener : IDisposable

Src/RT.Keyboard.csproj

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFrameworks>net481;net8.0-windows</TargetFrameworks>
5+
<UseWindowsForms>true</UseWindowsForms>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<DocumentationFile>$(OutputPath)\$(AssemblyName).xml</DocumentationFile>
8+
<LangVersion>latest</LangVersion>
9+
10+
<Version>1.0.0.9999</Version>
11+
<Authors>rstarkov;Timwi</Authors>
12+
<Description>GlobalKeyboardListener and other keyboard-related utilities.</Description>
13+
<PackageTags>rt.keyboard;GlobalKeyboardListener</PackageTags>
14+
</PropertyGroup>
15+
16+
</Project>

Src/UtWin.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
using System.Runtime.InteropServices;
22

3-
namespace RT.Util;
3+
namespace RT.Keyboard;
44

55
/// <summary>Offers some Windows-specific static functions which are hard to categorize under any more specific classes.</summary>
6-
public static partial class UtWin
6+
public static class UtWin
77
{
88
/// <summary>
99
/// Sends the specified sequence of key strokes to the active application. See remarks for details.</summary>

0 commit comments

Comments
 (0)