diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml
index e801455..d3681f5 100644
--- a/.github/workflows/publish.yml
+++ b/.github/workflows/publish.yml
@@ -19,11 +19,8 @@ jobs:
dotnet-version: |
9.0.x
- - name: Build - Debug
- run: dotnet build src/Interprocess.sln
-
- name: Test - Debug
- run: dotnet test --no-build --verbosity=detailed src/Interprocess.sln
+ run: dotnet test src/Interprocess.sln
- name: Build - Release
run: dotnet build -c Release src/Interprocess.sln
diff --git a/.vscode/launch.json b/.vscode/launch.json
new file mode 100644
index 0000000..94ba145
--- /dev/null
+++ b/.vscode/launch.json
@@ -0,0 +1,20 @@
+{
+ // Use IntelliSense to learn about possible attributes.
+ // Hover to view descriptions of existing attributes.
+ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
+ "version": "0.2.0",
+ "configurations": [
+ {
+ "name": "Publisher Sample",
+ "type": "dotnet",
+ "request": "launch",
+ "projectPath": "${workspaceFolder}/src/Sample/Publisher/Publisher.csproj"
+ },
+ {
+ "name": "Subscriber Sample",
+ "type": "dotnet",
+ "request": "launch",
+ "projectPath": "${workspaceFolder}/src/Sample/Subscriber/Subscriber.csproj"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/.vscode/settings.json b/.vscode/settings.json
index 2c44c10..17110cd 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -4,9 +4,12 @@
"Diagnoser",
"Interprocess",
"Kaby",
+ "Onnx",
"Pedram",
"Posix",
"Rezaei",
+ "Roslynator",
+ "Timespec",
"Xeon",
"Xunit"
]
diff --git a/.vscode/tasks.json b/.vscode/tasks.json
new file mode 100644
index 0000000..288fbb3
--- /dev/null
+++ b/.vscode/tasks.json
@@ -0,0 +1,25 @@
+{
+ "version": "2.0.0",
+ "tasks": [
+ {
+ "label": "build",
+ "type": "shell",
+ "command": "dotnet",
+ "args": [
+ "build",
+ "${workspaceFolder}/src"
+ ],
+ "group": {
+ "kind": "build",
+ "isDefault": true
+ },
+ "problemMatcher": [
+ "$msCompile"
+ ],
+ "presentation": {
+ "reveal": "always",
+ "panel": "shared"
+ }
+ },
+ ]
+}
\ No newline at end of file
diff --git a/README.md b/README.md
index 939d131..c89ed05 100644
--- a/README.md
+++ b/README.md
@@ -107,7 +107,6 @@ A lot has gone into optimizing the implementation of this library. For instance,
| Method | Description |
|------------------------------------------------ |-------------- |
-| Message enqueue | Benchmarks the performance of enqueuing a message. |
| Message enqueue and dequeue | Benchmarks the performance of sending a message to a client and receiving that message. It is inclusive of the duration to enqueue and dequeue a message. |
| Message enqueue and dequeue - no message buffer | Benchmarks the performance of sending a message to a client and receiving that message. It is inclusive of the duration to enqueue and dequeue a message and memory allocation for the received message. |
@@ -117,12 +116,6 @@ You can replicate the results by running the following command:
dotnet run Interprocess.Benchmark.csproj -c Release
```
-You can also be explicit about the .NET SDK and Runtime(s) versions:
-
-```sh
-dotnet run Interprocess.Benchmark.csproj -c Release -f net9.0 --runtimes net9.0
-```
-
---
### On Windows
@@ -141,7 +134,6 @@ Results:
| Method | Mean (ns) | Error (ns) | StdDev (ns) | Allocated |
|------------------------------------------------ |----------:|-----------:|------------:|----------:|
-| Message enqueue | `192.7`| `3.61`| `3.21`| `-` |
| Message enqueue and dequeue | `305.6`| `5.96`| `6.62`| `-` |
| Message enqueue and dequeue - no message buffer | `311.5`| `5.90`| `9.85`| `32 B` |
@@ -182,7 +174,6 @@ Results:
| Method | Mean (ns) | Error (ns) | StdDev (ns) | Allocated |
|------------------------------------------------ |----------:|-----------:|------------:|----------:|
-| Message enqueue | `5.3`| `-`| `-`| `-`|
| Message enqueue and dequeue | `169.9`| `3.08`| `4.01`| `-`|
| Message enqueue and dequeue - no message buffer | `179.4`| `1.91`| `1.60`| `32 B`|
diff --git a/src/.editorconfig b/src/.editorconfig
new file mode 100644
index 0000000..8d76caf
--- /dev/null
+++ b/src/.editorconfig
@@ -0,0 +1,712 @@
+# top-most EditorConfig file
+root = true
+
+# Don't use tabs for indentation.
+[*]
+end_of_line = lf
+indent_style = space
+
+# XML project files
+[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj}]
+indent_size = 2
+trim_trailing_whitespace = true
+
+# XML config files
+[*.{props,targets,ruleset,config,nuspec,resx,vsixmanifest,vsct}]
+indent_size = 2
+trim_trailing_whitespace = true
+
+[*.{liquid}]
+indent_size = 4
+
+# Powershell files
+[*.ps1]
+indent_size = 2
+
+# Shell script files
+[*.sh]
+indent_size = 2
+
+# JSON files
+[*.json]
+indent_size = 2
+trim_trailing_whitespace = true
+
+[*.{js,jsx,ts,tsx}]
+indent_size = 2
+trim_trailing_whitespace = true
+
+# Code files
+[*.{cs,csx,vb,vbx}]
+indent_size = 4
+trim_trailing_whitespace = true
+tab_width = 4
+
+[*.g.cs]
+dotnet_diagnostic.CS1591.severity = none
+
+[*.{cs,vb}]
+csharp_indent_labels = one_less_than_current
+csharp_prefer_braces = false:error
+csharp_prefer_simple_default_expression = true:error
+csharp_prefer_simple_using_statement = true:error
+csharp_prefer_static_local_function = true:error
+csharp_preserve_single_line_blocks = true:error
+csharp_space_around_binary_operators = before_and_after
+csharp_space_before_semicolon_in_for_statement = false
+csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = true:silent
+csharp_style_allow_blank_line_after_token_in_arrow_expression_clause_experimental = true:silent
+csharp_style_allow_blank_line_after_token_in_conditional_expression_experimental = true:silent
+csharp_style_allow_blank_lines_between_consecutive_braces_experimental = true:silent
+csharp_style_allow_embedded_statements_on_same_line_experimental = true:silent
+csharp_style_conditional_delegate_call = true:error
+csharp_style_deconstructed_variable_declaration = true:error
+csharp_style_expression_bodied_accessors = when_on_single_line:error
+csharp_style_expression_bodied_constructors = when_on_single_line:error
+csharp_style_expression_bodied_indexers = when_on_single_line:error
+csharp_style_expression_bodied_lambdas = when_on_single_line:error
+csharp_style_expression_bodied_local_functions = when_on_single_line:error
+csharp_style_expression_bodied_methods = when_on_single_line:error
+csharp_style_expression_bodied_operators = when_on_single_line:error
+csharp_style_expression_bodied_properties = when_on_single_line:error
+csharp_style_implicit_object_creation_when_type_is_apparent = true:error
+csharp_style_inlined_variable_declaration = true:error
+csharp_style_namespace_declarations = file_scoped:error
+csharp_style_pattern_matching_over_as_with_null_check = true:error
+csharp_style_pattern_matching_over_is_with_cast_check = true:error
+csharp_style_prefer_extended_property_pattern = true:suggestion
+csharp_style_prefer_index_operator = true:suggestion
+csharp_style_prefer_method_group_conversion = true:error
+csharp_style_prefer_not_pattern = true:error
+csharp_style_prefer_null_check_over_type_check = true:error
+csharp_style_prefer_pattern_matching = true:error
+csharp_style_prefer_readonly_struct = true:error
+csharp_style_prefer_readonly_struct_member = true:error
+csharp_style_prefer_switch_expression = true:error
+csharp_style_prefer_tuple_swap = true:error
+csharp_style_prefer_utf8_string_literals = true:error
+csharp_style_throw_expression = true:suggestion
+csharp_style_unused_value_assignment_preference = unused_local_variable:error
+csharp_style_var_elsewhere = true:error
+csharp_style_var_for_built_in_types = true:none
+csharp_style_var_when_type_is_apparent = true:error
+csharp_using_directive_placement = outside_namespace:error
+dotnet_code_quality_unused_parameters = all:error
+dotnet_naming_rule.interface_should_be_begins_with_i.severity = error
+dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i
+dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface
+dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = error
+dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case
+dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members
+dotnet_naming_rule.types_should_be_pascal_case.severity = error
+dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case
+dotnet_naming_rule.types_should_be_pascal_case.symbols = types
+dotnet_naming_style.begins_with_i.capitalization = pascal_case
+dotnet_naming_style.begins_with_i.required_prefix = I
+dotnet_naming_style.begins_with_i.required_suffix =
+dotnet_naming_style.begins_with_i.word_separator =
+dotnet_naming_style.pascal_case.capitalization = pascal_case
+dotnet_naming_style.pascal_case.required_prefix =
+dotnet_naming_style.pascal_case.required_suffix =
+dotnet_naming_style.pascal_case.word_separator =
+dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
+dotnet_naming_symbols.interface.applicable_kinds = interface
+dotnet_naming_symbols.interface.required_modifiers =
+dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
+dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method
+dotnet_naming_symbols.non_field_members.required_modifiers =
+dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
+dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum
+dotnet_naming_symbols.types.required_modifiers =
+dotnet_style_allow_multiple_blank_lines_experimental = false:error
+dotnet_style_allow_statement_immediately_after_block_experimental = true:silent
+dotnet_style_collection_initializer = true:error
+dotnet_style_explicit_tuple_names = true:error
+dotnet_style_namespace_match_folder = false:silent
+dotnet_style_null_propagation = true:error
+dotnet_style_object_initializer = true:suggestion
+dotnet_style_operator_placement_when_wrapping = beginning_of_line
+dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:error
+dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:error
+dotnet_style_parentheses_in_other_operators = never_if_unnecessary:error
+dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:error
+dotnet_style_predefined_type_for_locals_parameters_members = true:error
+dotnet_style_predefined_type_for_member_access = true:error
+dotnet_style_prefer_auto_properties = true:error
+dotnet_style_prefer_collection_expression = when_types_loosely_match:suggestion
+dotnet_style_prefer_compound_assignment = true:suggestion
+dotnet_style_prefer_conditional_expression_over_return = true:silent
+dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
+dotnet_style_prefer_inferred_tuple_names = true:suggestion
+dotnet_style_prefer_is_null_check_over_reference_equality_method = true:error
+dotnet_style_prefer_simplified_boolean_expressions = true:error
+dotnet_style_prefer_simplified_interpolation = true:error
+dotnet_style_qualification_for_event = false:error
+dotnet_style_qualification_for_field = false:error
+dotnet_style_qualification_for_method = false:error
+dotnet_style_qualification_for_property = false:error
+dotnet_style_readonly_field = true:error
+dotnet_style_require_accessibility_modifiers = for_non_interface_members:error
+insert_final_newline = false
+
+dotnet_diagnostic.ASP0000.severity = error
+dotnet_diagnostic.ASP0001.severity = error
+dotnet_diagnostic.ASP0002.severity = error
+dotnet_diagnostic.ASP0003.severity = error
+dotnet_diagnostic.ASP0004.severity = error
+dotnet_diagnostic.ASP0005.severity = error
+dotnet_diagnostic.ASP0006.severity = error
+dotnet_diagnostic.ASP0007.severity = error
+dotnet_diagnostic.ASP0008.severity = error
+dotnet_diagnostic.ASP0009.severity = error
+dotnet_diagnostic.ASP0010.severity = error
+dotnet_diagnostic.ASP0011.severity = error
+dotnet_diagnostic.ASP0012.severity = error
+dotnet_diagnostic.ASP0013.severity = error
+dotnet_diagnostic.ASP0014.severity = error
+dotnet_diagnostic.ASP0015.severity = error
+dotnet_diagnostic.ASP0016.severity = error
+dotnet_diagnostic.ASP0017.severity = error
+dotnet_diagnostic.ASP0018.severity = error
+dotnet_diagnostic.ASP0019.severity = error
+dotnet_diagnostic.ASP0020.severity = error
+dotnet_diagnostic.ASP0021.severity = error
+dotnet_diagnostic.ASP0022.severity = error
+dotnet_diagnostic.ASP0023.severity = error
+dotnet_diagnostic.ASP0024.severity = error
+dotnet_diagnostic.ASP0025.severity = error
+dotnet_diagnostic.ASP0026.severity = error
+dotnet_diagnostic.CA1000.severity = error
+dotnet_diagnostic.CA1001.severity = error
+dotnet_diagnostic.CA1002.severity = error
+dotnet_diagnostic.CA1005.severity = error
+dotnet_diagnostic.CA1008.severity = error
+dotnet_diagnostic.CA1010.severity = error
+dotnet_diagnostic.CA1012.severity = error
+dotnet_diagnostic.CA1014.severity = none
+dotnet_diagnostic.CA1016.severity = none
+dotnet_diagnostic.CA1017.severity = none
+dotnet_diagnostic.CA1018.severity = error
+dotnet_diagnostic.CA1021.severity = error
+dotnet_diagnostic.CA1028.severity = error
+dotnet_diagnostic.CA1031.severity = suggestion
+dotnet_diagnostic.CA1032.severity = none
+dotnet_diagnostic.CA1034.severity = error
+dotnet_diagnostic.CA1040.severity = none
+dotnet_diagnostic.CA1041.severity = error
+dotnet_diagnostic.CA1044.severity = error
+dotnet_diagnostic.CA1047.severity = error
+dotnet_diagnostic.CA1050.severity = error
+dotnet_diagnostic.CA1051.severity = error
+dotnet_diagnostic.CA1052.severity = error
+dotnet_diagnostic.CA1054.severity = none
+dotnet_diagnostic.CA1055.severity = none
+dotnet_diagnostic.CA1056.severity = none
+dotnet_diagnostic.CA1058.severity = error
+dotnet_diagnostic.CA1060.severity = error
+dotnet_diagnostic.CA1061.severity = error
+dotnet_diagnostic.CA1062.severity = suggestion
+dotnet_diagnostic.CA1063.severity = suggestion
+dotnet_diagnostic.CA1064.severity = none
+dotnet_diagnostic.CA1065.severity = error
+dotnet_diagnostic.CA1066.severity = error
+dotnet_diagnostic.CA1068.severity = error
+dotnet_diagnostic.CA1069.severity = error
+dotnet_diagnostic.CA1070.severity = error
+dotnet_diagnostic.CA1200.severity = error
+dotnet_diagnostic.CA1303.severity = none
+dotnet_diagnostic.CA1307.severity = error
+dotnet_diagnostic.CA1308.severity = none
+dotnet_diagnostic.CA1309.severity = error
+dotnet_diagnostic.CA1310.severity = error
+dotnet_diagnostic.CA1311.severity = error
+dotnet_diagnostic.CA1401.severity = error
+dotnet_diagnostic.CA1416.severity = error
+dotnet_diagnostic.CA1501.severity = error
+dotnet_diagnostic.CA1502.severity = error
+dotnet_diagnostic.CA1505.severity = error
+dotnet_diagnostic.CA1506.severity = none
+dotnet_diagnostic.CA1507.severity = error
+dotnet_diagnostic.CA1508.severity = error
+dotnet_diagnostic.CA1509.severity = error
+dotnet_diagnostic.CA1510.severity = error
+dotnet_diagnostic.CA1511.severity = error
+dotnet_diagnostic.CA1512.severity = error
+dotnet_diagnostic.CA1513.severity = error
+dotnet_diagnostic.CA1514.severity = error
+dotnet_diagnostic.CA1515.severity = error
+dotnet_diagnostic.CA1700.severity = error
+dotnet_code_quality.CA1707.api_surface = all
+dotnet_diagnostic.CA1707.severity = error
+dotnet_diagnostic.CA1708.severity = error
+dotnet_diagnostic.CA1710.severity = error
+dotnet_diagnostic.CA1711.severity = error
+dotnet_diagnostic.CA1712.severity = error
+dotnet_diagnostic.CA1715.severity = error
+dotnet_diagnostic.CA1716.severity = none
+dotnet_diagnostic.CA1717.severity = error
+dotnet_diagnostic.CA1720.severity = error
+dotnet_diagnostic.CA1721.severity = error
+dotnet_diagnostic.CA1724.severity = error
+dotnet_diagnostic.CA1725.severity = error
+dotnet_diagnostic.CA1727.severity = error
+dotnet_diagnostic.CA1802.severity = error
+dotnet_diagnostic.CA1805.severity = error
+dotnet_diagnostic.CA1806.severity = none
+dotnet_diagnostic.CA1810.severity = error
+dotnet_diagnostic.CA1812.severity = error
+dotnet_diagnostic.CA1813.severity = error
+dotnet_diagnostic.CA1816.severity = none
+dotnet_code_quality.CA1819.api_surface = all
+dotnet_diagnostic.CA1819.severity = error
+dotnet_diagnostic.CA1820.severity = error
+dotnet_diagnostic.CA1821.severity = error
+dotnet_diagnostic.CA1822.severity = error
+dotnet_diagnostic.CA1823.severity = error
+dotnet_diagnostic.CA1825.severity = error
+dotnet_code_quality.CA1826.exclude_ordefault_methods = true
+dotnet_diagnostic.CA1826.severity = error
+dotnet_diagnostic.CA1827.severity = error
+dotnet_diagnostic.CA1828.severity = error
+dotnet_diagnostic.CA1829.severity = error
+dotnet_diagnostic.CA1830.severity = error
+dotnet_diagnostic.CA1831.severity = error
+dotnet_diagnostic.CA1832.severity = error
+dotnet_diagnostic.CA1833.severity = error
+dotnet_diagnostic.CA1834.severity = error
+dotnet_diagnostic.CA1835.severity = error
+dotnet_diagnostic.CA1836.severity = error
+dotnet_diagnostic.CA1837.severity = error
+dotnet_diagnostic.CA1840.severity = error
+dotnet_diagnostic.CA1841.severity = error
+dotnet_diagnostic.CA1842.severity = error
+dotnet_diagnostic.CA1843.severity = error
+dotnet_diagnostic.CA1844.severity = error
+dotnet_diagnostic.CA1845.severity = error
+dotnet_diagnostic.CA1846.severity = error
+dotnet_diagnostic.CA1847.severity = error
+dotnet_diagnostic.CA1848.severity = error
+dotnet_diagnostic.CA1849.severity = error
+dotnet_diagnostic.CA1850.severity = error
+dotnet_diagnostic.CA1851.severity = error
+dotnet_code_quality.CA1852.ignore_internalsvisibleto = true
+dotnet_diagnostic.CA1852.severity = error
+dotnet_diagnostic.CA1853.severity = error
+dotnet_diagnostic.CA1854.severity = error
+dotnet_diagnostic.CA1855.severity = error
+dotnet_diagnostic.CA1856.severity = error
+dotnet_diagnostic.CA1857.severity = error
+dotnet_diagnostic.CA1858.severity = error
+dotnet_diagnostic.CA1859.severity = error
+dotnet_diagnostic.CA1861.severity = error
+dotnet_diagnostic.CA1862.severity = error
+dotnet_diagnostic.CA1863.severity = error
+dotnet_diagnostic.CA1864.severity = error
+dotnet_diagnostic.CA1865.severity = error
+dotnet_diagnostic.CA1866.severity = error
+dotnet_diagnostic.CA1867.severity = error
+dotnet_diagnostic.CA1868.severity = error
+dotnet_diagnostic.CA1869.severity = error
+dotnet_diagnostic.CA1870.severity = error
+dotnet_diagnostic.CA1871.severity = error
+dotnet_diagnostic.CA1872.severity = error
+dotnet_diagnostic.CA2000.severity = error
+dotnet_diagnostic.CA2002.severity = error
+dotnet_diagnostic.CA2007.severity = none
+dotnet_diagnostic.CA2008.severity = none
+dotnet_diagnostic.CA2009.severity = error
+dotnet_diagnostic.CA2011.severity = error
+dotnet_diagnostic.CA2012.severity = error
+dotnet_diagnostic.CA2013.severity = error
+dotnet_diagnostic.CA2014.severity = error
+dotnet_diagnostic.CA2015.severity = error
+dotnet_diagnostic.CA2016.severity = error
+dotnet_diagnostic.CA2017.severity = error
+dotnet_diagnostic.CA2018.severity = error
+dotnet_diagnostic.CA2019.severity = error
+dotnet_diagnostic.CA2021.severity = error
+dotnet_diagnostic.CA2022.severity = error
+dotnet_diagnostic.CA2101.severity = error
+dotnet_diagnostic.CA2200.severity = error
+dotnet_diagnostic.CA2201.severity = none
+dotnet_diagnostic.CA2207.severity = error
+dotnet_diagnostic.CA2208.severity = error
+dotnet_diagnostic.CA2211.severity = error
+dotnet_diagnostic.CA2213.severity = error
+dotnet_diagnostic.CA2214.severity = error
+dotnet_diagnostic.CA2215.severity = error
+dotnet_diagnostic.CA2216.severity = none
+dotnet_diagnostic.CA2217.severity = error
+dotnet_diagnostic.CA2219.severity = error
+dotnet_diagnostic.CA2227.severity = error
+dotnet_diagnostic.CA2234.severity = none
+dotnet_diagnostic.CA2242.severity = error
+dotnet_diagnostic.CA2244.severity = error
+dotnet_diagnostic.CA2245.severity = error
+dotnet_diagnostic.CA2247.severity = error
+dotnet_diagnostic.CA2248.severity = error
+dotnet_diagnostic.CA2249.severity = error
+dotnet_diagnostic.CA2250.severity = error
+dotnet_diagnostic.CA2251.severity = error
+dotnet_diagnostic.CA2253.severity = error
+dotnet_diagnostic.CA2254.severity = error
+dotnet_diagnostic.CA2259.severity = error
+dotnet_diagnostic.CA2260.severity = error
+dotnet_diagnostic.CA2261.severity = error
+dotnet_diagnostic.CA2262.severity = error
+dotnet_diagnostic.CA2263.severity = error
+dotnet_diagnostic.CA2264.severity = error
+dotnet_diagnostic.CA2265.severity = error
+dotnet_diagnostic.CA5392.severity = none
+dotnet_diagnostic.IDE0001.severity = error
+dotnet_diagnostic.IDE0002.severity = error
+dotnet_diagnostic.IDE0004.severity = error
+dotnet_diagnostic.IDE0005.severity = error
+dotnet_diagnostic.IDE0007.severity = error
+dotnet_diagnostic.IDE0010.severity = suggestion
+dotnet_diagnostic.IDE0020.severity = error
+dotnet_diagnostic.IDE0029.severity = error
+dotnet_diagnostic.IDE0030.severity = error
+dotnet_diagnostic.IDE0031.severity = error
+dotnet_diagnostic.IDE0036.severity = error
+dotnet_diagnostic.IDE0039.severity = error
+dotnet_diagnostic.IDE0041.severity = error
+dotnet_diagnostic.IDE0043.severity = error
+dotnet_diagnostic.IDE0045.severity = suggestion
+dotnet_diagnostic.IDE0046.severity = suggestion
+dotnet_diagnostic.IDE0049.severity = error
+dotnet_diagnostic.IDE0054.severity = error
+dotnet_diagnostic.IDE0057.severity = suggestion
+dotnet_diagnostic.IDE0058.severity = none
+dotnet_diagnostic.IDE0059.severity = error
+dotnet_diagnostic.IDE0060.severity = error
+dotnet_diagnostic.IDE0061.severity = error
+dotnet_diagnostic.IDE0062.severity = error
+dotnet_diagnostic.IDE0063.severity = error
+dotnet_diagnostic.IDE0064.severity = error
+dotnet_diagnostic.IDE0065.severity = error
+dotnet_diagnostic.IDE0066.severity = error
+dotnet_diagnostic.IDE0070.severity = error
+dotnet_diagnostic.IDE0071.severity = error
+dotnet_diagnostic.IDE0072.severity = none
+dotnet_diagnostic.IDE0073.severity = error
+dotnet_diagnostic.IDE0074.severity = error
+dotnet_diagnostic.IDE0075.severity = error
+dotnet_diagnostic.IDE0078.severity = error
+dotnet_diagnostic.IDE0079.severity = error
+dotnet_diagnostic.IDE0080.severity = error
+dotnet_diagnostic.IDE0081.severity = error
+dotnet_diagnostic.IDE0082.severity = error
+dotnet_diagnostic.IDE0083.severity = error
+dotnet_diagnostic.IDE0084.severity = error
+dotnet_diagnostic.IDE0090.severity = error
+dotnet_diagnostic.IDE0100.severity = error
+dotnet_diagnostic.IDE0110.severity = error
+dotnet_diagnostic.IDE0120.severity = error
+dotnet_diagnostic.IDE0130.severity = error
+dotnet_diagnostic.IDE0140.severity = error
+dotnet_diagnostic.IDE0150.severity = error
+dotnet_diagnostic.IDE0160.severity = error
+dotnet_diagnostic.IDE0161.severity = error
+dotnet_diagnostic.IDE0170.severity = error
+dotnet_diagnostic.IDE0180.severity = error
+dotnet_diagnostic.IDE0200.severity = error
+dotnet_diagnostic.IDE0210.severity = error
+dotnet_diagnostic.IDE0211.severity = error
+dotnet_diagnostic.IDE0220.severity = none
+dotnet_diagnostic.IDE0230.severity = error
+dotnet_diagnostic.IDE0240.severity = error
+dotnet_diagnostic.IDE0241.severity = error
+dotnet_diagnostic.IDE0250.severity = error
+dotnet_diagnostic.IDE0251.severity = error
+dotnet_diagnostic.IDE0260.severity = error
+dotnet_diagnostic.IDE0270.severity = suggestion
+dotnet_diagnostic.IDE0280.severity = error
+dotnet_diagnostic.IDE0290.severity = error
+dotnet_diagnostic.IDE0300.severity = error
+dotnet_diagnostic.IDE0301.severity = error
+dotnet_diagnostic.IDE0302.severity = error
+dotnet_diagnostic.IDE0303.severity = error
+dotnet_diagnostic.IDE0304.severity = error
+dotnet_diagnostic.IDE0305.severity = suggestion
+dotnet_diagnostic.IDE0320.severity = error
+dotnet_diagnostic.IDE0330.severity = error
+dotnet_diagnostic.IDE1005.severity = error
+dotnet_diagnostic.MVC1000.severity = error
+dotnet_diagnostic.MVC1001.severity = error
+dotnet_diagnostic.MVC1002.severity = error
+dotnet_diagnostic.MVC1003.severity = error
+dotnet_diagnostic.MVC1004.severity = error
+dotnet_diagnostic.MVC1005.severity = error
+dotnet_diagnostic.MVC1006.severity = error
+dotnet_diagnostic.SYSLIB1045.severity = error
+dotnet_diagnostic.SYSLIB1054.severity = error
+dotnet_diagnostic.VSTHRD001.severity = error
+dotnet_diagnostic.VSTHRD002.severity = error
+dotnet_diagnostic.VSTHRD003.severity = error
+dotnet_diagnostic.VSTHRD004.severity = error
+dotnet_diagnostic.VSTHRD010.severity = error
+dotnet_diagnostic.VSTHRD011.severity = error
+dotnet_diagnostic.VSTHRD012.severity = error
+dotnet_diagnostic.VSTHRD100.severity = error
+dotnet_diagnostic.VSTHRD101.severity = error
+dotnet_diagnostic.VSTHRD102.severity = error
+dotnet_diagnostic.VSTHRD103.severity = error
+dotnet_diagnostic.VSTHRD104.severity = error
+dotnet_diagnostic.VSTHRD105.severity = error
+dotnet_diagnostic.VSTHRD106.severity = error
+dotnet_diagnostic.VSTHRD107.severity = error
+dotnet_diagnostic.VSTHRD108.severity = error
+dotnet_diagnostic.VSTHRD109.severity = error
+dotnet_diagnostic.VSTHRD110.severity = error
+dotnet_diagnostic.VSTHRD111.severity = none
+dotnet_diagnostic.VSTHRD112.severity = error
+dotnet_diagnostic.VSTHRD113.severity = error
+dotnet_diagnostic.VSTHRD114.severity = error
+dotnet_diagnostic.VSTHRD115.severity = error
+dotnet_diagnostic.VSTHRD200.severity = error
+
+# StyleCop rules
+dotnet_diagnostic.SA0001.severity = none
+dotnet_diagnostic.SA1005.severity = none
+dotnet_diagnostic.SA1101.severity = none
+dotnet_diagnostic.SA1105.severity = none
+dotnet_diagnostic.SA1118.severity = none
+dotnet_diagnostic.SA1128.severity = none
+dotnet_diagnostic.SA1129.severity = error
+dotnet_diagnostic.SA1133.severity = none
+dotnet_diagnostic.SA1134.severity = none
+dotnet_diagnostic.SA1204.severity = none
+dotnet_diagnostic.SA1208.severity = error
+dotnet_diagnostic.SA1210.severity = error
+dotnet_diagnostic.SA1309.severity = error
+dotnet_diagnostic.SA1313.severity = suggestion
+dotnet_diagnostic.SA1402.severity = none
+dotnet_diagnostic.SA1413.severity = none
+dotnet_diagnostic.SA1502.severity = none
+dotnet_diagnostic.SA1503.severity = none
+dotnet_diagnostic.SA1512.severity = none
+dotnet_diagnostic.SA1513.severity = none
+dotnet_diagnostic.SA1514.severity = none
+dotnet_diagnostic.SA1515.severity = none
+dotnet_diagnostic.SA1516.severity = none
+dotnet_diagnostic.SA1600.severity = none
+dotnet_diagnostic.SA1601.severity = none
+dotnet_diagnostic.SA1602.severity = none
+dotnet_diagnostic.SA1604.severity = none
+dotnet_diagnostic.SA1611.severity = none
+dotnet_diagnostic.SA1612.severity = none
+dotnet_diagnostic.SA1614.severity = none
+dotnet_diagnostic.SA1615.severity = none
+dotnet_diagnostic.SA1618.severity = none
+dotnet_diagnostic.SA1623.severity = none
+dotnet_diagnostic.SA1629.severity = none
+dotnet_diagnostic.SA1633.severity = none
+dotnet_diagnostic.SA1642.severity = none
+dotnet_diagnostic.SA1649.severity = none
+
+# Roslynator analyzer
+roslynator_accessibility_modifiers = explicit
+roslynator_accessor_braces_style = single_line_when_expression_is_on_single_line
+roslynator_array_creation_type_style = implicit_when_type_is_obvious
+roslynator_arrow_token_new_line = after
+roslynator_binary_operator_new_line = before
+roslynator_blank_line_between_closing_brace_and_switch_section = true
+roslynator_blank_line_between_single_line_accessors = false
+roslynator_blank_line_between_switch_sections = omit
+roslynator_blank_line_between_using_directives = never
+roslynator_body_style = expression
+roslynator_conditional_operator_condition_parentheses_style = omit
+roslynator_conditional_operator_new_line = before
+roslynator_configure_await = false
+roslynator_equals_token_new_line = after
+roslynator_max_line_length = 120
+roslynator_new_line_before_while_in_do_statement = true
+roslynator_null_check_style = pattern_matching
+roslynator_null_conditional_operator_new_line = after
+roslynator_object_creation_parentheses_style = omit
+roslynator_object_creation_type_style = implicit_when_type_is_obvious
+roslynator_trailing_comma_style = omit
+roslynator_use_block_body_when_declaration_spans_over_multiple_lines = false
+roslynator_use_block_body_when_expression_spans_over_multiple_lines = false
+roslynator_use_collection_expression = true
+roslynator_use_var_instead_of_implicit_object_creation = true
+dotnet_diagnostic.RCS0001.severity = error
+dotnet_diagnostic.RCS0003.severity = error
+dotnet_diagnostic.RCS0011.severity = error
+dotnet_diagnostic.RCS0015.severity = error
+dotnet_diagnostic.RCS0020.severity = error
+dotnet_diagnostic.RCS0027.severity = error
+dotnet_diagnostic.RCS0028.severity = error
+dotnet_diagnostic.RCS0030.severity = error
+dotnet_diagnostic.RCS0032.severity = error
+dotnet_diagnostic.RCS0033.severity = error
+dotnet_diagnostic.RCS0041.severity = error
+dotnet_diagnostic.RCS0042.severity = error
+dotnet_diagnostic.RCS0045.severity = none
+dotnet_diagnostic.RCS0046.severity = error
+dotnet_diagnostic.RCS0050.severity = error
+dotnet_diagnostic.RCS0051.severity = error
+dotnet_diagnostic.RCS0052.severity = error
+dotnet_diagnostic.RCS0053.severity = error
+dotnet_diagnostic.RCS0054.severity = error
+dotnet_diagnostic.RCS0055.severity = error
+dotnet_diagnostic.RCS0056.severity = error
+dotnet_diagnostic.RCS0057.severity = error
+dotnet_diagnostic.RCS0059.severity = error
+dotnet_diagnostic.RCS0060.severity = error
+dotnet_diagnostic.RCS0061.severity = error
+dotnet_diagnostic.RCS1001.severity = error
+dotnet_diagnostic.RCS1002.severity = error
+dotnet_diagnostic.RCS1003.severity = error
+dotnet_diagnostic.RCS1004.severity = error
+dotnet_diagnostic.RCS1005.severity = error
+dotnet_diagnostic.RCS1006.severity = error
+dotnet_diagnostic.RCS1013.severity = error
+dotnet_diagnostic.RCS1015.severity = error
+dotnet_diagnostic.RCS1016.severity = error
+dotnet_diagnostic.RCS1018.severity = error
+dotnet_diagnostic.RCS1020.severity = error
+dotnet_diagnostic.RCS1021.severity = error
+dotnet_diagnostic.RCS1031.severity = error
+dotnet_diagnostic.RCS1032.severity = error
+dotnet_diagnostic.RCS1033.severity = error
+dotnet_diagnostic.RCS1034.severity = error
+dotnet_diagnostic.RCS1036.severity = error
+dotnet_diagnostic.RCS1037.severity = error
+dotnet_diagnostic.RCS1039.severity = error
+dotnet_diagnostic.RCS1042.severity = error
+dotnet_diagnostic.RCS1044.severity = error
+dotnet_diagnostic.RCS1046.severity = error
+dotnet_diagnostic.RCS1047.severity = error
+dotnet_diagnostic.RCS1048.severity = error
+dotnet_diagnostic.RCS1049.severity = error
+dotnet_diagnostic.RCS1050.severity = error
+dotnet_diagnostic.RCS1051.severity = error
+dotnet_diagnostic.RCS1055.severity = error
+dotnet_diagnostic.RCS1058.severity = error
+dotnet_diagnostic.RCS1059.severity = error
+dotnet_diagnostic.RCS1061.severity = error
+dotnet_diagnostic.RCS1068.severity = error
+dotnet_diagnostic.RCS1069.severity = error
+dotnet_diagnostic.RCS1070.severity = error
+dotnet_diagnostic.RCS1071.severity = error
+dotnet_diagnostic.RCS1073.severity = error
+dotnet_diagnostic.RCS1074.severity = error
+dotnet_diagnostic.RCS1077.severity = error
+dotnet_diagnostic.RCS1080.severity = error
+dotnet_diagnostic.RCS1084.severity = error
+dotnet_diagnostic.RCS1085.severity = error
+dotnet_diagnostic.RCS1089.severity = error
+dotnet_diagnostic.RCS1090.severity = error
+dotnet_diagnostic.RCS1093.severity = error
+dotnet_diagnostic.RCS1094.severity = error
+dotnet_diagnostic.RCS1096.severity = error
+dotnet_diagnostic.RCS1097.severity = error
+dotnet_diagnostic.RCS1098.severity = error
+dotnet_diagnostic.RCS1099.severity = error
+dotnet_diagnostic.RCS1102.severity = error
+dotnet_diagnostic.RCS1103.severity = error
+dotnet_diagnostic.RCS1104.severity = error
+dotnet_diagnostic.RCS1105.severity = error
+dotnet_diagnostic.RCS1107.severity = error
+dotnet_diagnostic.RCS1110.severity = error
+dotnet_diagnostic.RCS1112.severity = error
+dotnet_diagnostic.RCS1113.severity = error
+dotnet_diagnostic.RCS1114.severity = error
+dotnet_diagnostic.RCS1118.severity = error
+dotnet_diagnostic.RCS1123.severity = error
+dotnet_diagnostic.RCS1128.severity = error
+dotnet_diagnostic.RCS1129.severity = error
+dotnet_diagnostic.RCS1130.severity = error
+dotnet_diagnostic.RCS1132.severity = error
+dotnet_diagnostic.RCS1133.severity = error
+dotnet_diagnostic.RCS1134.severity = error
+dotnet_diagnostic.RCS1136.severity = error
+dotnet_diagnostic.RCS1143.severity = error
+dotnet_diagnostic.RCS1145.severity = error
+dotnet_diagnostic.RCS1146.severity = error
+dotnet_diagnostic.RCS1151.severity = error
+dotnet_diagnostic.RCS1154.severity = error
+dotnet_diagnostic.RCS1155.severity = error
+dotnet_diagnostic.RCS1156.severity = error
+dotnet_diagnostic.RCS1157.severity = error
+dotnet_diagnostic.RCS1158.severity = error
+dotnet_diagnostic.RCS1159.severity = error
+dotnet_diagnostic.RCS1160.severity = error
+dotnet_diagnostic.RCS1163.severity = error
+dotnet_diagnostic.RCS1164.severity = error
+dotnet_diagnostic.RCS1166.severity = error
+dotnet_diagnostic.RCS1168.severity = error
+dotnet_diagnostic.RCS1169.severity = error
+dotnet_diagnostic.RCS1170.severity = error
+dotnet_diagnostic.RCS1172.severity = error
+dotnet_diagnostic.RCS1173.severity = error
+dotnet_diagnostic.RCS1174.severity = error
+dotnet_diagnostic.RCS1175.severity = error
+dotnet_diagnostic.RCS1179.severity = error
+dotnet_diagnostic.RCS1182.severity = error
+dotnet_diagnostic.RCS1186.severity = error
+dotnet_diagnostic.RCS1187.severity = error
+dotnet_diagnostic.RCS1188.severity = error
+dotnet_diagnostic.RCS1190.severity = error
+dotnet_diagnostic.RCS1191.severity = error
+dotnet_diagnostic.RCS1192.severity = error
+dotnet_diagnostic.RCS1193.severity = error
+dotnet_diagnostic.RCS1194.severity = none
+dotnet_diagnostic.RCS1195.severity = error
+dotnet_diagnostic.RCS1196.severity = error
+dotnet_diagnostic.RCS1197.severity = error
+dotnet_diagnostic.RCS1198.severity = error
+dotnet_diagnostic.RCS1199.severity = error
+dotnet_diagnostic.RCS1200.severity = error
+dotnet_diagnostic.RCS1201.severity = error
+dotnet_diagnostic.RCS1202.severity = error
+dotnet_diagnostic.RCS1203.severity = error
+dotnet_diagnostic.RCS1204.severity = error
+dotnet_diagnostic.RCS1205.severity = error
+dotnet_diagnostic.RCS1206.severity = error
+dotnet_diagnostic.RCS1207.severity = error
+dotnet_diagnostic.RCS1209.severity = error
+dotnet_diagnostic.RCS1210.severity = error
+dotnet_diagnostic.RCS1211.severity = error
+dotnet_diagnostic.RCS1212.severity = error
+dotnet_diagnostic.RCS1213.severity = error
+dotnet_diagnostic.RCS1214.severity = error
+dotnet_diagnostic.RCS1215.severity = error
+dotnet_diagnostic.RCS1216.severity = error
+dotnet_diagnostic.RCS1218.severity = error
+dotnet_diagnostic.RCS1220.severity = error
+dotnet_diagnostic.RCS1221.severity = error
+dotnet_diagnostic.RCS1222.severity = none
+dotnet_diagnostic.RCS1225.severity = error
+dotnet_diagnostic.RCS1228.severity = error
+dotnet_diagnostic.RCS1229.severity = error
+dotnet_diagnostic.RCS1230.severity = error
+dotnet_diagnostic.RCS1231.severity = none # Make parameter ref read-only - should be avoided as it can have perf implications
+dotnet_diagnostic.RCS1232.severity = error
+dotnet_diagnostic.RCS1233.severity = error
+dotnet_diagnostic.RCS1234.severity = error
+dotnet_diagnostic.RCS1235.severity = error
+dotnet_diagnostic.RCS1236.severity = error
+dotnet_diagnostic.RCS1239.severity = error
+dotnet_diagnostic.RCS1240.severity = error
+dotnet_diagnostic.RCS1242.severity = error
+dotnet_diagnostic.RCS1243.severity = error
+dotnet_diagnostic.RCS1244.severity = error
+dotnet_diagnostic.RCS1246.severity = error
+dotnet_diagnostic.RCS1247.severity = error
+dotnet_diagnostic.RCS1248.severity = error
+dotnet_diagnostic.RCS1249.severity = error
+dotnet_diagnostic.RCS1251.severity = error
+dotnet_diagnostic.RCS1255.severity = error
+dotnet_diagnostic.RCS1256.severity = error
+dotnet_diagnostic.RCS1257.severity = error
+dotnet_diagnostic.RCS1259.severity = error
+dotnet_diagnostic.RCS1260.severity = error
+dotnet_diagnostic.RCS1261.severity = error
+dotnet_diagnostic.RCS1262.severity = error
+dotnet_diagnostic.RCS1263.severity = error
+dotnet_diagnostic.RCS1265.severity = error
+dotnet_diagnostic.RCS1267.severity = error
+dotnet_diagnostic.RCS1268.severity = error
\ No newline at end of file
diff --git a/src/Directory.Build.props b/src/Directory.Build.props
index 3ba3a75..fad57d8 100644
--- a/src/Directory.Build.props
+++ b/src/Directory.Build.props
@@ -2,27 +2,19 @@
- net9.0
+ net9.0
+ latest
+ enable
enable
true
true
true
+ true
+ true
+ false
+ true
+ All
+ false
-
-
- 1.0.*
- 1.0.*
- 9.0.*
-
-
-
-
-
- all
- runtime; build; native; contentfiles; analyzers
-
-
-
-
\ No newline at end of file
diff --git a/src/Directory.Packages.props b/src/Directory.Packages.props
new file mode 100644
index 0000000..de41659
--- /dev/null
+++ b/src/Directory.Packages.props
@@ -0,0 +1,43 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ all
+ runtime; build; native; contentfiles; analyzers
+
+
+ all
+ runtime; build; native; contentfiles; analyzers
+
+
+ all
+ runtime; build; native; contentfiles; analyzers
+
+
+ all
+ runtime; build; native; contentfiles; analyzers
+
+
+
+
\ No newline at end of file
diff --git a/src/Interprocess.Benchmark/.editorconfig b/src/Interprocess.Benchmark/.editorconfig
new file mode 100644
index 0000000..0e7e61e
--- /dev/null
+++ b/src/Interprocess.Benchmark/.editorconfig
@@ -0,0 +1,9 @@
+root = false
+
+[*.{cs,vb}]
+dotnet_diagnostic.CA1305.severity = none # Benchmark doesn't require formatters
+dotnet_diagnostic.CA1515.severity = none
+dotnet_diagnostic.CS1591.severity = none # Benchmark doesn't require XML comments
+dotnet_diagnostic.CA1707.severity = none # Benchmark doesn't require underscores in method names
+dotnet_diagnostic.CA1861.severity = none # Benchmark can use constant array arguments
+dotnet_diagnostic.VSTHRD003.severity = none # Avoid awaiting foreign Tasks
\ No newline at end of file
diff --git a/src/Interprocess.Benchmark/Interprocess.Benchmark.csproj b/src/Interprocess.Benchmark/Interprocess.Benchmark.csproj
index f576b8e..d96350c 100644
--- a/src/Interprocess.Benchmark/Interprocess.Benchmark.csproj
+++ b/src/Interprocess.Benchmark/Interprocess.Benchmark.csproj
@@ -6,7 +6,7 @@
-
+
diff --git a/src/Interprocess.Benchmark/Program.cs b/src/Interprocess.Benchmark/Program.cs
index 21bb044..d466157 100644
--- a/src/Interprocess.Benchmark/Program.cs
+++ b/src/Interprocess.Benchmark/Program.cs
@@ -1,12 +1,8 @@
-using BenchmarkDotNet.Running;
+using BenchmarkDotNet.Running;
-namespace Cloudtoid.Interprocess.Benchmark
+namespace Cloudtoid.Interprocess.Benchmark;
+
+public sealed class Program
{
- public sealed class Program
- {
- public static void Main()
- {
- _ = BenchmarkRunner.Run(typeof(Program).Assembly);
- }
- }
-}
+ public static void Main() => _ = BenchmarkRunner.Run(typeof(Program).Assembly);
+}
\ No newline at end of file
diff --git a/src/Interprocess.Benchmark/Queue/EnqueueBenchmark.cs b/src/Interprocess.Benchmark/Queue/EnqueueBenchmark.cs
index 4f6bbef..2164d68 100644
--- a/src/Interprocess.Benchmark/Queue/EnqueueBenchmark.cs
+++ b/src/Interprocess.Benchmark/Queue/EnqueueBenchmark.cs
@@ -1,50 +1,47 @@
-using System;
-using System.IO;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Jobs;
-namespace Cloudtoid.Interprocess.Benchmark
+namespace Cloudtoid.Interprocess.Benchmark;
+
+[SimpleJob(RuntimeMoniker.Net90)]
+[MemoryDiagnoser]
+[MarkdownExporterAttribute.GitHub]
+public class EnqueueBenchmark
{
- [SimpleJob(RuntimeMoniker.Net90)]
- [MemoryDiagnoser]
- [MarkdownExporterAttribute.GitHub]
- public class EnqueueBenchmark
- {
- private static readonly byte[] Message = new byte[] { 100, 110, 120 };
- private static readonly Memory MessageBuffer = new byte[Message.Length];
+ private static readonly byte[] Message = [100, 110, 120];
+ private static readonly Memory MessageBuffer = new byte[Message.Length];
#pragma warning disable CS8618
- private IPublisher publisher;
- private ISubscriber subscriber;
+ private IPublisher publisher;
+ private ISubscriber subscriber;
#pragma warning restore CS8618
- [GlobalSetup]
- public void Setup()
- {
- var queueFactory = new QueueFactory();
- publisher = queueFactory.CreatePublisher(new QueueOptions("qn", Path.GetTempPath(), 5120000));
- subscriber = queueFactory.CreateSubscriber(new QueueOptions("qn", Path.GetTempPath(), 5120000));
- }
+ [GlobalSetup]
+ public void Setup()
+ {
+ var queueFactory = new QueueFactory();
+ publisher = queueFactory.CreatePublisher(new QueueOptions("qn", Path.GetTempPath(), 5120000));
+ subscriber = queueFactory.CreateSubscriber(new QueueOptions("qn", Path.GetTempPath(), 5120000));
+ }
- [GlobalCleanup]
- public void Cleanup()
- {
- subscriber.Dispose();
- publisher.Dispose();
- }
+ [GlobalCleanup]
+ public void Cleanup()
+ {
+ subscriber.Dispose();
+ publisher.Dispose();
+ }
- [IterationCleanup]
- public void DrainQueue()
- {
- for (int i = 8; i < 320000; i++)
- subscriber.Dequeue(MessageBuffer, default);
- }
+ [IterationCleanup]
+ public void DrainQueue()
+ {
+ for (int i = 8; i < 320000; i++)
+ subscriber.Dequeue(MessageBuffer, default);
+ }
- // Expecting that there are NO managed heap allocations.
- [Benchmark(Description = "Message enqueue (320,000 times)")]
- public void Enqueue()
- {
- for (int i = 8; i < 320000; i++)
- publisher.TryEnqueue(Message);
- }
+ // Expecting that there are NO managed heap allocations.
+ [Benchmark(Description = "Message enqueue (320,000 times)")]
+ public void Enqueue()
+ {
+ for (int i = 8; i < 320000; i++)
+ publisher.TryEnqueue(Message);
}
-}
+}
\ No newline at end of file
diff --git a/src/Interprocess.Benchmark/Queue/QueueBenchmark.cs b/src/Interprocess.Benchmark/Queue/QueueBenchmark.cs
index 98c1a74..a40330f 100644
--- a/src/Interprocess.Benchmark/Queue/QueueBenchmark.cs
+++ b/src/Interprocess.Benchmark/Queue/QueueBenchmark.cs
@@ -1,54 +1,51 @@
-using System;
-using System.IO;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Jobs;
-namespace Cloudtoid.Interprocess.Benchmark
+namespace Cloudtoid.Interprocess.Benchmark;
+
+[SimpleJob(RuntimeMoniker.Net90)]
+[MemoryDiagnoser]
+[MarkdownExporterAttribute.GitHub]
+public class QueueBenchmark
{
- [SimpleJob(RuntimeMoniker.Net90)]
- [MemoryDiagnoser]
- [MarkdownExporterAttribute.GitHub]
- public class QueueBenchmark
- {
- private static readonly byte[] Message = new byte[] { 100, 110, 120 };
- private static readonly Memory MessageBuffer = new byte[Message.Length];
+ private static readonly byte[] Message = [100, 110, 120];
+ private static readonly Memory MessageBuffer = new byte[Message.Length];
#pragma warning disable CS8618
- private IPublisher publisher;
- private ISubscriber subscriber;
+ private IPublisher publisher;
+ private ISubscriber subscriber;
#pragma warning restore CS8618
- [GlobalSetup]
- public void Setup()
- {
- var queueFactory = new QueueFactory();
- publisher = queueFactory.CreatePublisher(new QueueOptions("qn", Path.GetTempPath(), 128));
- subscriber = queueFactory.CreateSubscriber(new QueueOptions("qn", Path.GetTempPath(), 128));
- }
-
- [GlobalCleanup]
- public void Cleanup()
- {
- subscriber.Dispose();
- publisher.Dispose();
- }
-
- [Benchmark(Description = "Message enqueue and dequeue - no message buffer")]
- public ReadOnlyMemory EnqueueDequeue_WithResultArrayAllocation()
- {
- if (!publisher.TryEnqueue(Message))
- throw new Exception("Failed to enqueue");
-
- return subscriber.Dequeue(default);
- }
-
- // Expecting that there are NO managed heap allocations.
- [Benchmark(Description = "Message enqueue and dequeue")]
- public ReadOnlyMemory EnqueueAndDequeue_WithPooledResultArray()
- {
- if (!publisher.TryEnqueue(Message))
- throw new Exception("Failed to enqueue");
-
- return subscriber.Dequeue(MessageBuffer, default);
- }
+ [GlobalSetup]
+ public void Setup()
+ {
+ var queueFactory = new QueueFactory();
+ publisher = queueFactory.CreatePublisher(new QueueOptions("qn", Path.GetTempPath(), 128));
+ subscriber = queueFactory.CreateSubscriber(new QueueOptions("qn", Path.GetTempPath(), 128));
+ }
+
+ [GlobalCleanup]
+ public void Cleanup()
+ {
+ subscriber.Dispose();
+ publisher.Dispose();
+ }
+
+ [Benchmark(Description = "Message enqueue and dequeue - no message buffer")]
+ public ReadOnlyMemory EnqueueDequeue_WithResultArrayAllocation()
+ {
+ if (!publisher.TryEnqueue(Message))
+ throw new Exception("Failed to enqueue");
+
+ return subscriber.Dequeue(default);
+ }
+
+ // Expecting that there are NO managed heap allocations.
+ [Benchmark(Description = "Message enqueue and dequeue")]
+ public ReadOnlyMemory EnqueueAndDequeue_WithPooledResultArray()
+ {
+ if (!publisher.TryEnqueue(Message))
+ throw new Exception("Failed to enqueue");
+
+ return subscriber.Dequeue(MessageBuffer, default);
}
-}
+}
\ No newline at end of file
diff --git a/src/Interprocess.Benchmark/Queue/QueueExtendedBenchmark.cs b/src/Interprocess.Benchmark/Queue/QueueExtendedBenchmark.cs
index 0bb603d..bed7be0 100644
--- a/src/Interprocess.Benchmark/Queue/QueueExtendedBenchmark.cs
+++ b/src/Interprocess.Benchmark/Queue/QueueExtendedBenchmark.cs
@@ -1,57 +1,54 @@
-using System;
-using System.IO;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Jobs;
-namespace Cloudtoid.Interprocess.Benchmark
+namespace Cloudtoid.Interprocess.Benchmark;
+
+[SimpleJob(RuntimeMoniker.Net90)]
+[MarkdownExporterAttribute.GitHub]
+public class QueueExtendedBenchmark
{
- [SimpleJob(RuntimeMoniker.Net90)]
- [MarkdownExporterAttribute.GitHub]
- public class QueueExtendedBenchmark
- {
- private static readonly byte[] Message = new byte[50];
- private static readonly byte[] MessageBuffer = new byte[Message.Length];
+ private static readonly byte[] Message = new byte[50];
+ private static readonly byte[] MessageBuffer = new byte[Message.Length];
#pragma warning disable CS8618
- private IPublisher publisher;
- private ISubscriber subscriber;
+ private IPublisher publisher;
+ private ISubscriber subscriber;
#pragma warning restore CS8618
- [GlobalSetup]
- public void Setup()
- {
- var queueFactory = new QueueFactory();
- publisher = queueFactory.CreatePublisher(new QueueOptions("qn", Path.GetTempPath(), 128));
- subscriber = queueFactory.CreateSubscriber(new QueueOptions("qn", Path.GetTempPath(), 128));
- }
-
- [GlobalCleanup]
- public void Cleanup()
- {
- subscriber.Dispose();
- publisher.Dispose();
- }
-
- [Benchmark(Description = "Message enqueue and dequeue - long message")]
- public ReadOnlyMemory EnqueueDequeue_LongMessage()
- {
- if (!publisher.TryEnqueue(Message))
- throw new Exception("Failed to enqueue");
-
- return subscriber.Dequeue(MessageBuffer, default);
- }
-
- [Benchmark(Description = "Message enqueue and dequeue - wrapped message in circular buffer")]
- public ReadOnlyMemory EnqueueDequeue_WrappedMessages()
- {
- if (!publisher.TryEnqueue(Message))
- throw new Exception("Failed to enqueue");
-
- subscriber.Dequeue(MessageBuffer, default);
-
- if (!publisher.TryEnqueue(Message))
- throw new Exception("Failed to enqueue");
-
- return subscriber.Dequeue(MessageBuffer, default);
- }
+ [GlobalSetup]
+ public void Setup()
+ {
+ var queueFactory = new QueueFactory();
+ publisher = queueFactory.CreatePublisher(new QueueOptions("qn", Path.GetTempPath(), 128));
+ subscriber = queueFactory.CreateSubscriber(new QueueOptions("qn", Path.GetTempPath(), 128));
+ }
+
+ [GlobalCleanup]
+ public void Cleanup()
+ {
+ subscriber.Dispose();
+ publisher.Dispose();
+ }
+
+ [Benchmark(Description = "Message enqueue and dequeue - long message")]
+ public ReadOnlyMemory EnqueueDequeue_LongMessage()
+ {
+ if (!publisher.TryEnqueue(Message))
+ throw new Exception("Failed to enqueue");
+
+ return subscriber.Dequeue(MessageBuffer, default);
+ }
+
+ [Benchmark(Description = "Message enqueue and dequeue - wrapped message in circular buffer")]
+ public ReadOnlyMemory EnqueueDequeue_WrappedMessages()
+ {
+ if (!publisher.TryEnqueue(Message))
+ throw new Exception("Failed to enqueue");
+
+ subscriber.Dequeue(MessageBuffer, default);
+
+ if (!publisher.TryEnqueue(Message))
+ throw new Exception("Failed to enqueue");
+
+ return subscriber.Dequeue(MessageBuffer, default);
}
-}
+}
\ No newline at end of file
diff --git a/src/Interprocess.Tests/.editorconfig b/src/Interprocess.Tests/.editorconfig
new file mode 100644
index 0000000..94f5394
--- /dev/null
+++ b/src/Interprocess.Tests/.editorconfig
@@ -0,0 +1,10 @@
+root = false
+
+[*.{cs,vb}]
+dotnet_diagnostic.CA1305.severity = none # Tests don't require formatters
+dotnet_diagnostic.CA1515.severity = none
+dotnet_diagnostic.CS1591.severity = none # Tests don't require XML comments
+dotnet_diagnostic.CA1707.severity = none # Tests don't require underscores in method names
+dotnet_diagnostic.CA1861.severity = none # Tests can use constant array arguments
+dotnet_diagnostic.MSTEST0030.severity = error # Type containing '[TestMethod]' should be marked with '[TestClass]'
+dotnet_diagnostic.VSTHRD003.severity = none # Avoid awaiting foreign Tasks
\ No newline at end of file
diff --git a/src/Interprocess.Tests/CircularBufferTests.cs b/src/Interprocess.Tests/CircularBufferTests.cs
index 1e0a8a5..f954135 100644
--- a/src/Interprocess.Tests/CircularBufferTests.cs
+++ b/src/Interprocess.Tests/CircularBufferTests.cs
@@ -1,149 +1,151 @@
-using System.Linq;
using FluentAssertions;
using Xunit;
-namespace Cloudtoid.Interprocess.Tests
+namespace Cloudtoid.Interprocess.Tests;
+
+public unsafe class CircularBufferTests
{
- public unsafe class CircularBufferTests
- {
- private static readonly byte[] ByteArray1 = new byte[] { 100, };
- private static readonly byte[] ByteArray2 = new byte[] { 100, 110 };
- private static readonly byte[] ByteArray3 = new byte[] { 100, 110, 120 };
+ private static readonly byte[] ByteArray = [100, 110, 120];
- [Theory]
- [InlineData(new byte[] { 100 }, 0, 0)]
- [InlineData(new byte[] { 100 }, 1, 0)]
- [InlineData(new byte[] { 100 }, 2, 0)]
- [InlineData(new byte[] { 100 }, 3, 0)]
- [InlineData(new byte[] { 100, 110 }, 0, 0)]
- [InlineData(new byte[] { 100, 110 }, 1, 1)]
- [InlineData(new byte[] { 100, 110 }, 2, 0)]
- [InlineData(new byte[] { 100, 110 }, 3, 1)]
- public void CanAdjustOffset(byte[] bytes, long offset, long adjustedOffset)
+ [Theory]
+ [InlineData(new byte[] { 100 }, 0, 0)]
+ [InlineData(new byte[] { 100 }, 1, 0)]
+ [InlineData(new byte[] { 100 }, 2, 0)]
+ [InlineData(new byte[] { 100 }, 3, 0)]
+ [InlineData(new byte[] { 100, 110 }, 0, 0)]
+ [InlineData(new byte[] { 100, 110 }, 1, 1)]
+ [InlineData(new byte[] { 100, 110 }, 2, 0)]
+ [InlineData(new byte[] { 100, 110 }, 3, 1)]
+ public void CanAdjustOffset(byte[] bytes, long offset, long adjustedOffset)
+ {
+ fixed (byte* bytesPtr = &bytes[0])
{
- fixed (byte* bytesPtr = &bytes[0])
- {
- var buffer = new CircularBuffer(bytesPtr, bytes.Length);
- buffer.Capacity.Should().Be(bytes.Length);
- buffer.AdjustedOffset(ref offset);
- offset.Should().Be(adjustedOffset);
- }
+ var buffer = new CircularBuffer(bytesPtr, bytes.Length);
+ buffer.Capacity.Should().Be(bytes.Length);
+ buffer.AdjustedOffset(ref offset);
+ offset.Should().Be(adjustedOffset);
}
+ }
- [Theory]
- [InlineData(new byte[] { 100 }, 0, 100)]
- [InlineData(new byte[] { 100 }, 1, 100)]
- [InlineData(new byte[] { 100 }, 2, 100)]
- [InlineData(new byte[] { 100 }, 3, 100)]
- [InlineData(new byte[] { 100, 110 }, 0, 100)]
- [InlineData(new byte[] { 100, 110 }, 1, 110)]
- [InlineData(new byte[] { 100, 110 }, 2, 100)]
- [InlineData(new byte[] { 100, 110 }, 3, 110)]
- public void CanGetPointer(byte[] bytes, long offset, byte expectedValue)
+ [Theory]
+ [InlineData(new byte[] { 100 }, 0, 100)]
+ [InlineData(new byte[] { 100 }, 1, 100)]
+ [InlineData(new byte[] { 100 }, 2, 100)]
+ [InlineData(new byte[] { 100 }, 3, 100)]
+ [InlineData(new byte[] { 100, 110 }, 0, 100)]
+ [InlineData(new byte[] { 100, 110 }, 1, 110)]
+ [InlineData(new byte[] { 100, 110 }, 2, 100)]
+ [InlineData(new byte[] { 100, 110 }, 3, 110)]
+ public void CanGetPointer(byte[] bytes, long offset, byte expectedValue)
+ {
+ fixed (byte* bytesPtr = &bytes[0])
{
- fixed (byte* bytesPtr = &bytes[0])
- {
- var buffer = new CircularBuffer(bytesPtr, bytes.Length);
- buffer.Capacity.Should().Be(bytes.Length);
- var b = *buffer.GetPointer(offset);
- b.Should().Be(expectedValue);
- }
+ var buffer = new CircularBuffer(bytesPtr, bytes.Length);
+ buffer.Capacity.Should().Be(bytes.Length);
+ var b = *buffer.GetPointer(offset);
+ b.Should().Be(expectedValue);
}
+ }
- [Theory]
- [InlineData(0, 0, new byte[] { })]
- [InlineData(0, 1, new byte[] { 100 })]
- [InlineData(1, 1, new byte[] { 110 })]
- [InlineData(2, 1, new byte[] { 120 })]
- [InlineData(3, 1, new byte[] { 100 })]
- [InlineData(0, 2, new byte[] { 100, 110 })]
- [InlineData(1, 2, new byte[] { 110, 120 })]
- [InlineData(2, 2, new byte[] { 120, 100 })]
- [InlineData(3, 2, new byte[] { 100, 110 })]
- [InlineData(0, 3, new byte[] { 100, 110, 120 })]
- [InlineData(1, 3, new byte[] { 110, 120, 100 })]
- [InlineData(2, 3, new byte[] { 120, 100, 110 })]
- [InlineData(3, 3, new byte[] { 100, 110, 120 })]
- [InlineData(0, 4, new byte[] { 100, 110, 120, 100 })]
- [InlineData(1, 4, new byte[] { 110, 120, 100, 110 })]
- [InlineData(0, 0, new byte[] { }, 1)]
- [InlineData(1, 4, new byte[] { 110 }, 1)]
- [InlineData(1, 2, new byte[] { 110, 120 }, 6)]
- public void CanRead(long offset, int length, byte[] expectedResult, int? bufferLength = null)
+ [Theory]
+ [InlineData(0, 0, new byte[] { })]
+ [InlineData(0, 1, new byte[] { 100 })]
+ [InlineData(1, 1, new byte[] { 110 })]
+ [InlineData(2, 1, new byte[] { 120 })]
+ [InlineData(3, 1, new byte[] { 100 })]
+ [InlineData(0, 2, new byte[] { 100, 110 })]
+ [InlineData(1, 2, new byte[] { 110, 120 })]
+ [InlineData(2, 2, new byte[] { 120, 100 })]
+ [InlineData(3, 2, new byte[] { 100, 110 })]
+ [InlineData(0, 3, new byte[] { 100, 110, 120 })]
+ [InlineData(1, 3, new byte[] { 110, 120, 100 })]
+ [InlineData(2, 3, new byte[] { 120, 100, 110 })]
+ [InlineData(3, 3, new byte[] { 100, 110, 120 })]
+ [InlineData(0, 4, new byte[] { 100, 110, 120, 100 })]
+ [InlineData(1, 4, new byte[] { 110, 120, 100, 110 })]
+ [InlineData(0, 0, new byte[] { }, 1)]
+ [InlineData(1, 4, new byte[] { 110 }, 1)]
+ [InlineData(1, 2, new byte[] { 110, 120 }, 6)]
+ public void CanRead(long offset, int length, byte[] expectedResult, int? bufferLength = null)
+ {
+ fixed (byte* bytesPtr = &ByteArray[0])
{
- fixed (byte* bytesPtr = &ByteArray3[0])
- {
- var buffer = new CircularBuffer(bytesPtr, ByteArray3.Length);
- if (bufferLength is null)
- buffer.Read(offset, length).ToArray().Should().BeEquivalentTo(expectedResult);
+ var buffer = new CircularBuffer(bytesPtr, ByteArray.Length);
+ if (bufferLength is null)
+ buffer.Read(offset, length).ToArray().Should().BeEquivalentTo(expectedResult);
- var resultBuffer = new byte[bufferLength ?? length];
- buffer.Read(offset, length, resultBuffer).ToArray().Should().BeEquivalentTo(expectedResult);
- }
+ var resultBuffer = new byte[bufferLength ?? length];
+ buffer.Read(offset, length, resultBuffer).ToArray().Should().BeEquivalentTo(expectedResult);
}
+ }
- [Theory]
- [InlineData(0, 0, new byte[] { })]
- [InlineData(0, 1, new byte[] { 100 })]
- [InlineData(1, 1, new byte[] { 110 })]
- [InlineData(2, 1, new byte[] { 120 })]
- [InlineData(3, 1, new byte[] { 100 })]
- [InlineData(0, 2, new byte[] { 100, 110 })]
- [InlineData(1, 2, new byte[] { 110, 120 })]
- [InlineData(2, 2, new byte[] { 120, 100 })]
- [InlineData(3, 2, new byte[] { 100, 110 })]
- [InlineData(0, 3, new byte[] { 100, 110, 120 })]
- [InlineData(1, 3, new byte[] { 110, 120, 100 })]
- [InlineData(2, 3, new byte[] { 120, 100, 110 })]
- [InlineData(3, 3, new byte[] { 100, 110, 120 })]
- public void CanWrite(long offset, long length, byte[] bytes)
+ [Theory]
+ [InlineData(0, 0, new byte[] { })]
+ [InlineData(0, 1, new byte[] { 100 })]
+ [InlineData(1, 1, new byte[] { 110 })]
+ [InlineData(2, 1, new byte[] { 120 })]
+ [InlineData(3, 1, new byte[] { 100 })]
+ [InlineData(0, 2, new byte[] { 100, 110 })]
+ [InlineData(1, 2, new byte[] { 110, 120 })]
+ [InlineData(2, 2, new byte[] { 120, 100 })]
+ [InlineData(3, 2, new byte[] { 100, 110 })]
+ [InlineData(0, 3, new byte[] { 100, 110, 120 })]
+ [InlineData(1, 3, new byte[] { 110, 120, 100 })]
+ [InlineData(2, 3, new byte[] { 120, 100, 110 })]
+ [InlineData(3, 3, new byte[] { 100, 110, 120 })]
+ public void CanWrite(long offset, long length, byte[] bytes)
+ {
+ var b = new byte[3];
+ fixed (byte* ptr = &b[0])
{
- var b = new byte[3];
- fixed (byte* ptr = &b[0])
- {
- var buffer = new CircularBuffer(ptr, b.Length);
- buffer.Write(bytes, offset);
- buffer.Read(offset, length).ToArray().Should().BeEquivalentTo(bytes);
- }
+ var buffer = new CircularBuffer(ptr, b.Length);
+ buffer.Write(bytes, offset);
+ buffer.Read(offset, length).ToArray().Should().BeEquivalentTo(bytes);
}
+ }
- [Fact]
- public void CanWriteStruct()
+ [Fact]
+ public void CanWriteStruct()
+ {
+ var b = new byte[sizeof(QueueHeader)];
+ fixed (byte* ptr = &b[0])
{
- var b = new byte[sizeof(QueueHeader)];
- fixed (byte* ptr = &b[0])
+ var buffer = new CircularBuffer(ptr, b.Length);
+ var value = new QueueHeader
{
- var buffer = new CircularBuffer(ptr, b.Length);
- var value = new QueueHeader { ReadOffset = 1, WriteOffset = 2, ReadLockTimestamp = long.MaxValue, Reserved = long.MinValue };
- buffer.Write(value, 0);
- value.Should().BeEquivalentTo(*(QueueHeader*)ptr);
- }
+ ReadOffset = 1,
+ WriteOffset = 2,
+ ReadLockTimestamp = long.MaxValue,
+ Reserved = long.MinValue
+ };
+ buffer.Write(value, 0);
+ value.Should().BeEquivalentTo(*(QueueHeader*)ptr);
}
+ }
- [Theory]
- [InlineData(0, 0)]
- [InlineData(0, 1)]
- [InlineData(1, 1)]
- [InlineData(2, 1)]
- [InlineData(3, 1)]
- [InlineData(0, 2)]
- [InlineData(1, 2)]
- [InlineData(2, 2)]
- [InlineData(3, 2)]
- [InlineData(0, 3)]
- [InlineData(1, 3)]
- [InlineData(2, 3)]
- [InlineData(3, 3)]
- public void CanZeroBlock(long offset, long length)
+ [Theory]
+ [InlineData(0, 0)]
+ [InlineData(0, 1)]
+ [InlineData(1, 1)]
+ [InlineData(2, 1)]
+ [InlineData(3, 1)]
+ [InlineData(0, 2)]
+ [InlineData(1, 2)]
+ [InlineData(2, 2)]
+ [InlineData(3, 2)]
+ [InlineData(0, 3)]
+ [InlineData(1, 3)]
+ [InlineData(2, 3)]
+ [InlineData(3, 3)]
+ public void CanZeroBlock(long offset, long length)
+ {
+ var b = new byte[3] { 1, 1, 1 };
+ fixed (byte* ptr = &b[0])
{
- var b = new byte[3] { 1, 1, 1 };
- fixed (byte* ptr = &b[0])
- {
- var buffer = new CircularBuffer(ptr, b.Length);
- buffer.Read(offset, length).ToArray().All(i => i == 1).Should().BeTrue();
- buffer.Clear(offset, length);
- buffer.Read(offset, length).ToArray().All(i => i == 0).Should().BeTrue();
- }
+ var buffer = new CircularBuffer(ptr, b.Length);
+ buffer.Read(offset, length).ToArray().All(i => i == 1).Should().BeTrue();
+ buffer.Clear(offset, length);
+ buffer.Read(offset, length).ToArray().All(i => i == 0).Should().BeTrue();
}
}
-}
+}
\ No newline at end of file
diff --git a/src/Interprocess.Tests/Interprocess.Tests.csproj b/src/Interprocess.Tests/Interprocess.Tests.csproj
index 48e4189..edc2ae5 100644
--- a/src/Interprocess.Tests/Interprocess.Tests.csproj
+++ b/src/Interprocess.Tests/Interprocess.Tests.csproj
@@ -8,12 +8,12 @@
-
-
-
-
-
-
+
+
+
+
+
+
diff --git a/src/Interprocess.Tests/Properties/AssemblyInfo.cs b/src/Interprocess.Tests/Properties/AssemblyInfo.cs
index 87ebd04..94c43b9 100644
--- a/src/Interprocess.Tests/Properties/AssemblyInfo.cs
+++ b/src/Interprocess.Tests/Properties/AssemblyInfo.cs
@@ -1,3 +1,3 @@
-using System.Diagnostics.CodeAnalysis;
+using System.Diagnostics.CodeAnalysis;
-[assembly: ExcludeFromCodeCoverage]
+[assembly: ExcludeFromCodeCoverage]
\ No newline at end of file
diff --git a/src/Interprocess.Tests/QueueTests.cs b/src/Interprocess.Tests/QueueTests.cs
index 1b90b02..160541a 100644
--- a/src/Interprocess.Tests/QueueTests.cs
+++ b/src/Interprocess.Tests/QueueTests.cs
@@ -1,251 +1,248 @@
-using System.Diagnostics.CodeAnalysis;
-using System.Linq;
-using System.Threading;
-using System.Threading.Tasks;
-using FluentAssertions;
-using Microsoft.Extensions.DependencyInjection;
-using Microsoft.Extensions.Logging;
-using Xunit;
-using Xunit.Abstractions;
-
-namespace Cloudtoid.Interprocess.Tests
-{
- public class QueueTests : IClassFixture
- {
- private static readonly byte[] ByteArray1 = new byte[] { 100, };
- private static readonly byte[] ByteArray2 = new byte[] { 100, 110 };
- private static readonly byte[] ByteArray3 = new byte[] { 100, 110, 120 };
- private static readonly byte[] ByteArray50 = Enumerable.Range(1, 50).Select(i => (byte)i).ToArray();
- private readonly UniquePathFixture fixture;
- private readonly QueueFactory queueFactory;
-
- public QueueTests(
- UniquePathFixture fixture,
- ITestOutputHelper testOutputHelper)
- {
- this.fixture = fixture;
- var loggerFactory = new LoggerFactory();
- loggerFactory.AddProvider(new XunitLoggerProvider(testOutputHelper));
- queueFactory = new QueueFactory(loggerFactory);
- }
-
- [Fact]
- [TestBeforeAfter]
- public void Sample()
- {
- var message = new byte[] { 1, 2, 3 };
- var messageBuffer = new byte[3];
- CancellationToken cancellationToken = default;
-
- var factory = new QueueFactory();
- var options = new QueueOptions(
- queueName: "my-queue",
- capacity: 1024 * 1024);
-
- using var publisher = factory.CreatePublisher(options);
- publisher.TryEnqueue(message);
-
- options = new QueueOptions(
- queueName: "my-queue",
- capacity: 1024 * 1024);
-
- using var subscriber = factory.CreateSubscriber(options);
- subscriber.TryDequeue(messageBuffer, cancellationToken, out var msg);
-
- msg.ToArray().Should().BeEquivalentTo(message);
- }
-
- [Fact]
- [TestBeforeAfter]
- public void DependencyInjectionSample()
- {
- var message = new byte[] { 1, 2, 3 };
- var messageBuffer = new byte[3];
- CancellationToken cancellationToken = default;
- var services = new ServiceCollection();
-
- services
- .AddInterprocessQueue() // adding the queue related components
- .AddLogging(); // optionally, we can enable logging
-
- var serviceProvider = services.BuildServiceProvider();
- var factory = serviceProvider.GetRequiredService();
-
- var options = new QueueOptions(
- queueName: "my-queue",
- capacity: 1024 * 1024);
-
- using var publisher = factory.CreatePublisher(options);
- publisher.TryEnqueue(message);
-
- options = new QueueOptions(
- queueName: "my-queue",
- capacity: 1024 * 1024);
-
- using var subscriber = factory.CreateSubscriber(options);
- subscriber.TryDequeue(messageBuffer, cancellationToken, out var msg);
-
- msg.ToArray().Should().BeEquivalentTo(message);
- }
-
- [Fact]
- [TestBeforeAfter]
- public void CanEnqueueAndDequeue()
- {
- using var p = CreatePublisher(24);
- using var s = CreateSubscriber(24);
-
- p.TryEnqueue(ByteArray3).Should().BeTrue();
- var message = s.Dequeue(default);
- message.ToArray().Should().BeEquivalentTo(ByteArray3);
-
- p.TryEnqueue(ByteArray3).Should().BeTrue();
- message = s.Dequeue(default);
- message.ToArray().Should().BeEquivalentTo(ByteArray3);
-
- p.TryEnqueue(ByteArray2).Should().BeTrue();
- message = s.Dequeue(default);
- message.ToArray().Should().BeEquivalentTo(ByteArray2);
-
- p.TryEnqueue(ByteArray2).Should().BeTrue();
- message = s.Dequeue(new byte[5], default);
- message.ToArray().Should().BeEquivalentTo(ByteArray2);
- }
-
- [Fact]
- [TestBeforeAfter]
- public void CanEnqueueDequeueWrappedMessage()
- {
- using var p = CreatePublisher(128);
- using var s = CreateSubscriber(128);
-
- p.TryEnqueue(ByteArray50).Should().BeTrue();
- var message = s.Dequeue(default);
- message.ToArray().Should().BeEquivalentTo(ByteArray50);
-
- p.TryEnqueue(ByteArray50).Should().BeTrue();
- message = s.Dequeue(default);
- message.ToArray().Should().BeEquivalentTo(ByteArray50);
-
- p.TryEnqueue(ByteArray50).Should().BeTrue();
- message = s.Dequeue(default);
- message.ToArray().Should().BeEquivalentTo(ByteArray50);
-
- p.TryEnqueue(ByteArray50).Should().BeTrue();
- message = s.Dequeue(default);
- message.ToArray().Should().BeEquivalentTo(ByteArray50);
- }
-
- [Fact]
- [TestBeforeAfter]
- public void CannotEnqueuePastCapacity()
- {
- using var p = CreatePublisher(24);
-
- p.TryEnqueue(ByteArray3).Should().BeTrue();
- p.TryEnqueue(ByteArray1).Should().BeFalse();
- }
-
- [Fact]
- [TestBeforeAfter]
- public void DisposeShouldNotThrow()
- {
- var p = CreatePublisher(24);
- p.TryEnqueue(ByteArray3).Should().BeTrue();
-
- using var s = CreateSubscriber(24);
- p.Dispose();
-
- s.Dequeue(default);
- }
-
- [Fact]
- [TestBeforeAfter]
- public void CannotReadAfterProducerIsDisposed()
- {
- var p = CreatePublisher(24);
- p.TryEnqueue(ByteArray3).Should().BeTrue();
- using (var s = CreateSubscriber(24))
- p.Dispose();
-
- using (CreatePublisher(24))
- using (var s = CreateSubscriber(24))
- {
- s.TryDequeue(default, out var message).Should().BeFalse();
- }
- }
-
- [Theory]
- [Repeat(10)]
- [TestBeforeAfter]
- [SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "The extra argument is needed by the Repeat attribute.")]
- [SuppressMessage("Usage", "xUnit1026:Theory methods should use all of their parameters", Justification = "The extra argument is needed by the Repeat attribute.")]
- public async Task CanDisposeQueueAsync(int i)
- {
- using (var s = CreateSubscriber(1024))
- {
- _ = Task.Run(() => s.Dequeue(default));
- await Task.Delay(200);
- }
- }
-
- [Fact]
- [TestBeforeAfter]
- public void CanCircleBuffer()
- {
- using var p = CreatePublisher(1024);
- using var s = CreateSubscriber(1024);
-
- var message = Enumerable.Range(100, 66).Select(i => (byte)i).ToArray();
-
- for (var i = 0; i < 20000; i++)
- {
- p.TryEnqueue(message).Should().BeTrue();
- var result = s.Dequeue(default);
- result.ToArray().Should().BeEquivalentTo(message);
- }
- }
-
- [Fact]
- [TestBeforeAfter]
- public void CanRejectLargeMessages()
- {
- using (var p = CreatePublisher(24))
- using (var s = CreateSubscriber(24))
- {
- p.TryEnqueue(ByteArray3).Should().BeTrue();
- var message = s.Dequeue(default);
- message.ToArray().Should().BeEquivalentTo(ByteArray3);
-
- p.TryEnqueue(ByteArray3).Should().BeTrue();
-
- // This should fail because the queue is out of capacity
- p.TryEnqueue(ByteArray3).Should().BeFalse();
-
- message = s.Dequeue(default);
- message.ToArray().Should().BeEquivalentTo(ByteArray3);
-
- p.TryEnqueue(ByteArray3).Should().BeTrue();
- p.TryEnqueue(ByteArray3).Should().BeFalse();
- }
-
- using (var p = CreatePublisher(32))
- {
- p.TryEnqueue(ByteArray3).Should().BeTrue();
- p.TryEnqueue(ByteArray3).Should().BeTrue();
- p.TryEnqueue(ByteArray3).Should().BeFalse();
- }
-
- using (var p = CreatePublisher(32))
- p.TryEnqueue(ByteArray50).Should().BeFalse(); // failed here
- }
-
- private IPublisher CreatePublisher(long capacity)
- => queueFactory.CreatePublisher(
- new QueueOptions("qn", fixture.Path, capacity));
-
- private ISubscriber CreateSubscriber(long capacity)
- => queueFactory.CreateSubscriber(
- new QueueOptions("qn", fixture.Path, capacity));
- }
-}
+using FluentAssertions;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Logging;
+using Xunit;
+using Xunit.Abstractions;
+
+namespace Cloudtoid.Interprocess.Tests;
+
+public class QueueTests : IClassFixture
+{
+ private static readonly byte[] ByteArray1 = [100,];
+ private static readonly byte[] ByteArray2 = [100, 110];
+ private static readonly byte[] ByteArray3 = [100, 110, 120];
+ private static readonly byte[] ByteArray50 = Enumerable.Range(1, 50).Select(i => (byte)i).ToArray();
+ private readonly UniquePathFixture fixture;
+ private readonly QueueFactory queueFactory;
+
+ public QueueTests(
+ UniquePathFixture fixture,
+ ITestOutputHelper testOutputHelper)
+ {
+ this.fixture = fixture;
+#pragma warning disable CA2000 // Dispose objects before losing scope
+ var loggerFactory = new LoggerFactory();
+ loggerFactory.AddProvider(new XunitLoggerProvider(testOutputHelper));
+#pragma warning restore CA2000 // Dispose objects before losing scope
+ queueFactory = new QueueFactory(loggerFactory);
+ }
+
+ [Fact]
+ [TestBeforeAfter]
+ public void Sample()
+ {
+ var message = new byte[] { 1, 2, 3 };
+ var messageBuffer = new byte[3];
+ CancellationToken cancellationToken = default;
+
+ var factory = new QueueFactory();
+ var options = new QueueOptions(
+ queueName: "my-queue",
+ capacity: 1024 * 1024);
+
+ using var publisher = factory.CreatePublisher(options);
+ publisher.TryEnqueue(message);
+
+ options = new QueueOptions(
+ queueName: "my-queue",
+ capacity: 1024 * 1024);
+
+ using var subscriber = factory.CreateSubscriber(options);
+ subscriber.TryDequeue(messageBuffer, cancellationToken, out var msg);
+
+ msg.ToArray().Should().BeEquivalentTo(message);
+ }
+
+ [Fact]
+ [TestBeforeAfter]
+ public void DependencyInjectionSample()
+ {
+ var message = new byte[] { 1, 2, 3 };
+ var messageBuffer = new byte[3];
+ CancellationToken cancellationToken = default;
+ var services = new ServiceCollection();
+
+ services
+ .AddInterprocessQueue() // adding the queue related components
+ .AddLogging(); // optionally, we can enable logging
+
+ var serviceProvider = services.BuildServiceProvider();
+ var factory = serviceProvider.GetRequiredService();
+
+ var options = new QueueOptions(
+ queueName: "my-queue",
+ capacity: 1024 * 1024);
+
+ using var publisher = factory.CreatePublisher(options);
+ publisher.TryEnqueue(message);
+
+ options = new QueueOptions(
+ queueName: "my-queue",
+ capacity: 1024 * 1024);
+
+ using var subscriber = factory.CreateSubscriber(options);
+ subscriber.TryDequeue(messageBuffer, cancellationToken, out var msg);
+
+ msg.ToArray().Should().BeEquivalentTo(message);
+ }
+
+ [Fact]
+ [TestBeforeAfter]
+ public void CanEnqueueAndDequeue()
+ {
+ using var p = CreatePublisher(24);
+ using var s = CreateSubscriber(24);
+
+ p.TryEnqueue(ByteArray3).Should().BeTrue();
+ var message = s.Dequeue(default);
+ message.ToArray().Should().BeEquivalentTo(ByteArray3);
+
+ p.TryEnqueue(ByteArray3).Should().BeTrue();
+ message = s.Dequeue(default);
+ message.ToArray().Should().BeEquivalentTo(ByteArray3);
+
+ p.TryEnqueue(ByteArray2).Should().BeTrue();
+ message = s.Dequeue(default);
+ message.ToArray().Should().BeEquivalentTo(ByteArray2);
+
+ p.TryEnqueue(ByteArray2).Should().BeTrue();
+ message = s.Dequeue(new byte[5], default);
+ message.ToArray().Should().BeEquivalentTo(ByteArray2);
+ }
+
+ [Fact]
+ [TestBeforeAfter]
+ public void CanEnqueueDequeueWrappedMessage()
+ {
+ using var p = CreatePublisher(128);
+ using var s = CreateSubscriber(128);
+
+ p.TryEnqueue(ByteArray50).Should().BeTrue();
+ var message = s.Dequeue(default);
+ message.ToArray().Should().BeEquivalentTo(ByteArray50);
+
+ p.TryEnqueue(ByteArray50).Should().BeTrue();
+ message = s.Dequeue(default);
+ message.ToArray().Should().BeEquivalentTo(ByteArray50);
+
+ p.TryEnqueue(ByteArray50).Should().BeTrue();
+ message = s.Dequeue(default);
+ message.ToArray().Should().BeEquivalentTo(ByteArray50);
+
+ p.TryEnqueue(ByteArray50).Should().BeTrue();
+ message = s.Dequeue(default);
+ message.ToArray().Should().BeEquivalentTo(ByteArray50);
+ }
+
+ [Fact]
+ [TestBeforeAfter]
+ public void CannotEnqueuePastCapacity()
+ {
+ using var p = CreatePublisher(24);
+
+ p.TryEnqueue(ByteArray3).Should().BeTrue();
+ p.TryEnqueue(ByteArray1).Should().BeFalse();
+ }
+
+ [Fact]
+ [TestBeforeAfter]
+ public void DisposeShouldNotThrow()
+ {
+ var p = CreatePublisher(24);
+ p.TryEnqueue(ByteArray3).Should().BeTrue();
+
+ using var s = CreateSubscriber(24);
+ p.Dispose();
+
+ s.Dequeue(default);
+ }
+
+ [Fact]
+ [TestBeforeAfter]
+ public void CannotReadAfterProducerIsDisposed()
+ {
+ var p = CreatePublisher(24);
+ p.TryEnqueue(ByteArray3).Should().BeTrue();
+ using (var s = CreateSubscriber(24))
+ p.Dispose();
+
+ using (CreatePublisher(24))
+ using (var s = CreateSubscriber(24))
+ s.TryDequeue(default, out var message).Should().BeFalse();
+ }
+
+ [Theory]
+ [Repeat(10)]
+ [TestBeforeAfter]
+#pragma warning disable RCS1163 // Unused parameter
+#pragma warning disable IDE0060 // Remove unused parameter
+#pragma warning disable xUnit1026 // Theory methods should use all of their parameters
+ public async Task CanDisposeQueueAsync(int i)
+#pragma warning restore xUnit1026 // Theory methods should use all of their parameters
+#pragma warning restore IDE0060 // Remove unused parameter
+#pragma warning restore RCS1163 // Unused parameter
+ {
+ using var s = CreateSubscriber(1024);
+ _ = Task.Run(() => s.Dequeue(default));
+ await Task.Delay(200);
+ }
+
+ [Fact]
+ [TestBeforeAfter]
+ public void CanCircleBuffer()
+ {
+ using var p = CreatePublisher(1024);
+ using var s = CreateSubscriber(1024);
+
+ var message = Enumerable.Range(100, 66).Select(i => (byte)i).ToArray();
+
+ for (var i = 0; i < 20000; i++)
+ {
+ p.TryEnqueue(message).Should().BeTrue();
+ var result = s.Dequeue(default);
+ result.ToArray().Should().BeEquivalentTo(message);
+ }
+ }
+
+ [Fact]
+ [TestBeforeAfter]
+ public void CanRejectLargeMessages()
+ {
+ using (var p = CreatePublisher(24))
+ using (var s = CreateSubscriber(24))
+ {
+ p.TryEnqueue(ByteArray3).Should().BeTrue();
+ var message = s.Dequeue(default);
+ message.ToArray().Should().BeEquivalentTo(ByteArray3);
+
+ p.TryEnqueue(ByteArray3).Should().BeTrue();
+
+ // This should fail because the queue is out of capacity
+ p.TryEnqueue(ByteArray3).Should().BeFalse();
+
+ message = s.Dequeue(default);
+ message.ToArray().Should().BeEquivalentTo(ByteArray3);
+
+ p.TryEnqueue(ByteArray3).Should().BeTrue();
+ p.TryEnqueue(ByteArray3).Should().BeFalse();
+ }
+
+ using (var p = CreatePublisher(32))
+ {
+ p.TryEnqueue(ByteArray3).Should().BeTrue();
+ p.TryEnqueue(ByteArray3).Should().BeTrue();
+ p.TryEnqueue(ByteArray3).Should().BeFalse();
+ }
+
+ using (var p = CreatePublisher(32))
+ p.TryEnqueue(ByteArray50).Should().BeFalse(); // failed here
+ }
+
+ private IPublisher CreatePublisher(long capacity) =>
+ queueFactory.CreatePublisher(
+ new QueueOptions("qn", fixture.Path, capacity));
+
+ private ISubscriber CreateSubscriber(long capacity) =>
+ queueFactory.CreateSubscriber(
+ new QueueOptions("qn", fixture.Path, capacity));
+}
\ No newline at end of file
diff --git a/src/Interprocess.Tests/SemaphoreTests.cs b/src/Interprocess.Tests/SemaphoreTests.cs
index b1426ad..7139a83 100644
--- a/src/Interprocess.Tests/SemaphoreTests.cs
+++ b/src/Interprocess.Tests/SemaphoreTests.cs
@@ -1,123 +1,122 @@
-using Cloudtoid.Interprocess.Semaphore.Linux;
+using Cloudtoid.Interprocess.Semaphore.Linux;
using Cloudtoid.Interprocess.Semaphore.MacOS;
using FluentAssertions;
-namespace Cloudtoid.Interprocess.Tests
+namespace Cloudtoid.Interprocess.Tests;
+
+public class SemaphoreTests
{
- public class SemaphoreTests
+ [Fact(Platforms = Platform.Linux | Platform.FreeBSD)]
+ [TestBeforeAfter]
+ public void CanReleaseAndWaitLinux()
+ {
+ using var sem = new SemaphoreLinux("my-sem", deleteOnDispose: true);
+ sem.Wait(10).Should().BeFalse();
+ sem.Release();
+ sem.Release();
+ sem.Wait(-1).Should().BeTrue();
+ sem.Wait(10).Should().BeTrue();
+ sem.Wait(0).Should().BeFalse();
+ sem.Wait(10).Should().BeFalse();
+ sem.Release();
+ sem.Wait(10).Should().BeTrue();
+ }
+
+ [Fact(Platforms = Platform.OSX)]
+ [TestBeforeAfter]
+ public void CanReleaseAndWaitMacOS()
+ {
+ using var sem = new SemaphoreMacOS("my-sem", deleteOnDispose: true);
+ sem.Wait(10).Should().BeFalse();
+ sem.Release();
+ sem.Release();
+ sem.Wait(-1).Should().BeTrue();
+ sem.Wait(10).Should().BeTrue();
+ sem.Wait(0).Should().BeFalse();
+ sem.Wait(10).Should().BeFalse();
+ sem.Release();
+ sem.Wait(10).Should().BeTrue();
+ }
+
+ [Fact(Platforms = Platform.Linux | Platform.FreeBSD)]
+ [TestBeforeAfter]
+ public void CanCreateMultipleSemaphoresWithSameNameLinux()
+ {
+ using var sem1 = new SemaphoreLinux("my-sem", deleteOnDispose: true);
+ using var sem2 = new SemaphoreLinux("my-sem", deleteOnDispose: false);
+ sem2.Release();
+ sem1.Wait(10).Should().BeTrue();
+ sem1.Wait(10).Should().BeFalse();
+ sem2.Wait(10).Should().BeFalse();
+ }
+
+ [Fact(Platforms = Platform.OSX)]
+ [TestBeforeAfter]
+ public void CanCreateMultipleSemaphoresWithSameNameMacOS()
+ {
+ using var sem1 = new SemaphoreMacOS("my-sem", deleteOnDispose: true);
+ using var sem2 = new SemaphoreMacOS("my-sem", deleteOnDispose: false);
+ sem2.Release();
+ sem1.Wait(10).Should().BeTrue();
+ sem1.Wait(10).Should().BeFalse();
+ sem2.Wait(10).Should().BeFalse();
+ }
+
+ [Fact(Platforms = Platform.Linux | Platform.FreeBSD)]
+ [TestBeforeAfter]
+ public void CanReuseSameSemaphoreNameLinux()
{
- [Fact(Platforms = Platform.Linux | Platform.FreeBSD)]
- [TestBeforeAfter]
- public void CanReleaseAndWaitLinux()
+ using (var sem = new SemaphoreLinux("my-sem", deleteOnDispose: true))
{
- using var sem = new SemaphoreLinux("my-sem", deleteOnDispose: true);
sem.Wait(10).Should().BeFalse();
sem.Release();
- sem.Release();
sem.Wait(-1).Should().BeTrue();
- sem.Wait(10).Should().BeTrue();
- sem.Wait(0).Should().BeFalse();
- sem.Wait(10).Should().BeFalse();
sem.Release();
- sem.Wait(10).Should().BeTrue();
}
- [Fact(Platforms = Platform.OSX)]
- [TestBeforeAfter]
- public void CanReleaseAndWaitMacOS()
+ using (var sem = new SemaphoreLinux("my-sem", deleteOnDispose: false))
{
- using var sem = new SemaphoreMacOS("my-sem", deleteOnDispose: true);
sem.Wait(10).Should().BeFalse();
sem.Release();
- sem.Release();
sem.Wait(-1).Should().BeTrue();
- sem.Wait(10).Should().BeTrue();
- sem.Wait(0).Should().BeFalse();
- sem.Wait(10).Should().BeFalse();
sem.Release();
- sem.Wait(10).Should().BeTrue();
}
- [Fact(Platforms = Platform.Linux | Platform.FreeBSD)]
- [TestBeforeAfter]
- public void CanCreateMultipleSemaphoresWithSameNameLinux()
+ using (var sem = new SemaphoreLinux("my-sem", deleteOnDispose: true))
{
- using var sem1 = new SemaphoreLinux("my-sem", deleteOnDispose: true);
- using var sem2 = new SemaphoreLinux("my-sem", deleteOnDispose: false);
- sem2.Release();
- sem1.Wait(10).Should().BeTrue();
- sem1.Wait(10).Should().BeFalse();
- sem2.Wait(10).Should().BeFalse();
+ sem.Wait(10).Should().BeTrue();
+ sem.Release();
+ sem.Wait(-1).Should().BeTrue();
+ sem.Release();
}
+ }
- [Fact(Platforms = Platform.OSX)]
- [TestBeforeAfter]
- public void CanCreateMultipleSemaphoresWithSameNameMacOS()
+ [Fact(Platforms = Platform.OSX)]
+ [TestBeforeAfter]
+ public void CanReuseSameSemaphoreNameMacOS()
+ {
+ using (var sem = new SemaphoreMacOS("my-sem", deleteOnDispose: true))
{
- using var sem1 = new SemaphoreMacOS("my-sem", deleteOnDispose: true);
- using var sem2 = new SemaphoreMacOS("my-sem", deleteOnDispose: false);
- sem2.Release();
- sem1.Wait(10).Should().BeTrue();
- sem1.Wait(10).Should().BeFalse();
- sem2.Wait(10).Should().BeFalse();
+ sem.Wait(10).Should().BeFalse();
+ sem.Release();
+ sem.Wait(-1).Should().BeTrue();
+ sem.Release();
}
- [Fact(Platforms = Platform.Linux | Platform.FreeBSD)]
- [TestBeforeAfter]
- public void CanReuseSameSemaphoreNameLinux()
+ using (var sem = new SemaphoreMacOS("my-sem", deleteOnDispose: false))
{
- using (var sem = new SemaphoreLinux("my-sem", deleteOnDispose: true))
- {
- sem.Wait(10).Should().BeFalse();
- sem.Release();
- sem.Wait(-1).Should().BeTrue();
- sem.Release();
- }
-
- using (var sem = new SemaphoreLinux("my-sem", deleteOnDispose: false))
- {
- sem.Wait(10).Should().BeFalse();
- sem.Release();
- sem.Wait(-1).Should().BeTrue();
- sem.Release();
- }
-
- using (var sem = new SemaphoreLinux("my-sem", deleteOnDispose: true))
- {
- sem.Wait(10).Should().BeTrue();
- sem.Release();
- sem.Wait(-1).Should().BeTrue();
- sem.Release();
- }
+ sem.Wait(10).Should().BeFalse();
+ sem.Release();
+ sem.Wait(-1).Should().BeTrue();
+ sem.Release();
}
- [Fact(Platforms = Platform.OSX)]
- [TestBeforeAfter]
- public void CanReuseSameSemaphoreNameMacOS()
+ using (var sem = new SemaphoreMacOS("my-sem", deleteOnDispose: true))
{
- using (var sem = new SemaphoreMacOS("my-sem", deleteOnDispose: true))
- {
- sem.Wait(10).Should().BeFalse();
- sem.Release();
- sem.Wait(-1).Should().BeTrue();
- sem.Release();
- }
-
- using (var sem = new SemaphoreMacOS("my-sem", deleteOnDispose: false))
- {
- sem.Wait(10).Should().BeFalse();
- sem.Release();
- sem.Wait(-1).Should().BeTrue();
- sem.Release();
- }
-
- using (var sem = new SemaphoreMacOS("my-sem", deleteOnDispose: true))
- {
- sem.Wait(10).Should().BeTrue();
- sem.Release();
- sem.Wait(-1).Should().BeTrue();
- sem.Release();
- }
+ sem.Wait(10).Should().BeTrue();
+ sem.Release();
+ sem.Wait(-1).Should().BeTrue();
+ sem.Release();
}
}
-}
+}
\ No newline at end of file
diff --git a/src/Interprocess.Tests/Utils/FactAttribute.cs b/src/Interprocess.Tests/Utils/FactAttribute.cs
index 46d6db7..691dc75 100644
--- a/src/Interprocess.Tests/Utils/FactAttribute.cs
+++ b/src/Interprocess.Tests/Utils/FactAttribute.cs
@@ -1,46 +1,45 @@
-using System.Runtime.InteropServices;
+using System.Runtime.InteropServices;
-namespace Cloudtoid.Interprocess.Tests
+namespace Cloudtoid.Interprocess.Tests;
+
+public sealed class FactAttribute : Xunit.FactAttribute
{
- public class FactAttribute : Xunit.FactAttribute
- {
- private static readonly Platform? CurrentPlatform = GetPlatform();
+ private static readonly Platform? CurrentPlatform = GetPlatform();
- ///
- /// Gets or sets the supported OS Platforms
- ///
- public Platform Platforms { get; set; } = Platform.All;
+ ///
+ /// Gets or sets the supported OS Platforms
+ ///
+ public Platform Platforms { get; set; } = Platform.All;
- public override string? Skip
+ public override string? Skip
+ {
+ get
{
- get
- {
- if (base.Skip != null || CurrentPlatform is null)
- return base.Skip;
+ if (base.Skip is not null || CurrentPlatform is null)
+ return base.Skip;
- if ((Platforms & CurrentPlatform) == 0)
- return $"Skipped on {CurrentPlatform}";
+ if ((Platforms & CurrentPlatform) == 0)
+ return $"Skipped on {CurrentPlatform}";
- return null;
- }
- set => base.Skip = value;
+ return null;
}
+ set => base.Skip = value;
+ }
- private static Platform? GetPlatform()
- {
- if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
- return Platform.Windows;
+ private static Platform? GetPlatform()
+ {
+ if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
+ return Platform.Windows;
- if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
- return Platform.Linux;
+ if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
+ return Platform.Linux;
- if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
- return Platform.OSX;
+ if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
+ return Platform.OSX;
- if (RuntimeInformation.IsOSPlatform(OSPlatform.FreeBSD))
- return Platform.FreeBSD;
+ if (RuntimeInformation.IsOSPlatform(OSPlatform.FreeBSD))
+ return Platform.FreeBSD;
- return null;
- }
+ return null;
}
}
\ No newline at end of file
diff --git a/src/Interprocess.Tests/Utils/Platform.cs b/src/Interprocess.Tests/Utils/Platform.cs
index 2978c47..7e11235 100644
--- a/src/Interprocess.Tests/Utils/Platform.cs
+++ b/src/Interprocess.Tests/Utils/Platform.cs
@@ -1,16 +1,13 @@
-using System;
+namespace Cloudtoid.Interprocess.Tests;
-namespace Cloudtoid.Interprocess.Tests
+[Flags]
+public enum Platform
{
- [Flags]
- public enum Platform
- {
- Windows = 0x01,
- Linux = 0x02,
- OSX = 0x04,
- FreeBSD = 0x08,
+ Windows = 0x01,
+ Linux = 0x02,
+ OSX = 0x04,
+ FreeBSD = 0x08,
- UnixBased = Linux | OSX | FreeBSD,
- All = Windows | Linux | OSX | FreeBSD
- }
+ UnixBased = Linux | OSX | FreeBSD,
+ All = Windows | Linux | OSX | FreeBSD
}
\ No newline at end of file
diff --git a/src/Interprocess.Tests/Utils/RepeatAttribute.cs b/src/Interprocess.Tests/Utils/RepeatAttribute.cs
index a36f63d..a80f2d8 100644
--- a/src/Interprocess.Tests/Utils/RepeatAttribute.cs
+++ b/src/Interprocess.Tests/Utils/RepeatAttribute.cs
@@ -1,24 +1,13 @@
-using System.Collections.Generic;
-using System.Linq;
using System.Reflection;
using Xunit.Sdk;
-namespace Cloudtoid.Interprocess.Tests
-{
- public sealed class RepeatAttribute : DataAttribute
- {
- private readonly int count;
+namespace Cloudtoid.Interprocess.Tests;
- public RepeatAttribute(int count)
- {
- this.count = count;
- }
+public sealed class RepeatAttribute(int count) : DataAttribute
+{
+ public int Count { get; } = count;
- public override IEnumerable