com.wallstop-studios.unity-helpers 2.0.0-rc47 → 2.0.0-rc49

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 1,
3
+ "isRoot": true,
4
+ "tools": {
5
+ "CSharpier": {
6
+ "version": "0.30.6",
7
+ "commands": ["dotnet-csharpier"]
8
+ }
9
+ }
10
+ }
package/.editorconfig ADDED
@@ -0,0 +1,184 @@
1
+
2
+ [*]
3
+ charset = utf-8-bom
4
+ end_of_line = crlf
5
+ trim_trailing_whitespace = false
6
+ insert_final_newline = false
7
+ indent_style = space
8
+ indent_size = 4
9
+
10
+ # Microsoft .NET properties
11
+ csharp_new_line_before_members_in_object_initializers = false
12
+ csharp_preferred_modifier_order = public, private, protected, internal, file, new, static, abstract, virtual, sealed, readonly, override, extern, unsafe, volatile, async, required:suggestion
13
+ csharp_prefer_braces = true:suggestion
14
+ csharp_style_prefer_utf8_string_literals = true:suggestion
15
+ csharp_style_var_elsewhere = false:suggestion
16
+ csharp_style_var_for_built_in_types = false:suggestion
17
+ csharp_style_var_when_type_is_apparent = false:suggestion
18
+ csharp_using_directive_placement = inside_namespace:silent
19
+ dotnet_naming_rule.event_rule.import_to_resharper = True
20
+ dotnet_naming_rule.event_rule.resharper_description = Events
21
+ dotnet_naming_rule.event_rule.resharper_guid = 0c4c6401-2a1f-4db1-a21f-562f51542cf8
22
+ dotnet_naming_rule.event_rule.severity = warning
23
+ dotnet_naming_rule.event_rule.style = on_upper_camel_case_style
24
+ dotnet_naming_rule.event_rule.symbols = event_symbols
25
+ dotnet_naming_rule.interfaces_rule.import_to_resharper = True
26
+ dotnet_naming_rule.interfaces_rule.resharper_description = Interfaces
27
+ dotnet_naming_rule.interfaces_rule.resharper_guid = a7a3339e-4e89-4319-9735-a9dc4cb74cc7
28
+ dotnet_naming_rule.interfaces_rule.severity = warning
29
+ dotnet_naming_rule.interfaces_rule.style = i_upper_camel_case_style
30
+ dotnet_naming_rule.interfaces_rule.symbols = interfaces_symbols
31
+ dotnet_naming_rule.local_constants_rule.import_to_resharper = True
32
+ dotnet_naming_rule.local_constants_rule.resharper_description = Local constants
33
+ dotnet_naming_rule.local_constants_rule.resharper_guid = a4f433b8-abcd-4e55-a08f-82e78cef0f0c
34
+ dotnet_naming_rule.local_constants_rule.resharper_style = AaBb, aaBb
35
+ dotnet_naming_rule.local_constants_rule.severity = warning
36
+ dotnet_naming_rule.local_constants_rule.style = upper_camel_case_style
37
+ dotnet_naming_rule.local_constants_rule.symbols = local_constants_symbols
38
+ dotnet_naming_rule.public_fields_override_rule.import_to_resharper = False
39
+ dotnet_naming_rule.public_fields_override_rule.severity = warning
40
+ dotnet_naming_rule.public_fields_override_rule.style = upper_camel_case_style
41
+ dotnet_naming_rule.public_fields_override_rule.symbols = public_fields_override_symbols
42
+ dotnet_naming_rule.public_fields_override_rule_1.import_to_resharper = False
43
+ dotnet_naming_rule.public_fields_override_rule_1.severity = warning
44
+ dotnet_naming_rule.public_fields_override_rule_1.style = upper_camel_case_style
45
+ dotnet_naming_rule.public_fields_override_rule_1.symbols = public_fields_override_symbols_1
46
+ dotnet_naming_rule.public_fields_rule.import_to_resharper = True
47
+ dotnet_naming_rule.public_fields_rule.resharper_description = Instance fields (not private)
48
+ dotnet_naming_rule.public_fields_rule.resharper_guid = 53eecf85-d821-40e8-ac97-fdb734542b84
49
+ dotnet_naming_rule.public_fields_rule.severity = warning
50
+ dotnet_naming_rule.public_fields_rule.style = lower_camel_case_style
51
+ dotnet_naming_rule.public_fields_rule.symbols = public_fields_symbols
52
+ dotnet_naming_rule.public_static_fields_rule.import_to_resharper = True
53
+ dotnet_naming_rule.public_static_fields_rule.resharper_description = Static fields (not private)
54
+ dotnet_naming_rule.public_static_fields_rule.resharper_guid = 70345118-4b40-4ece-937c-bbeb7a0b2e70
55
+ dotnet_naming_rule.public_static_fields_rule.severity = warning
56
+ dotnet_naming_rule.public_static_fields_rule.style = upper_camel_case_style
57
+ dotnet_naming_rule.public_static_fields_rule.symbols = public_static_fields_symbols
58
+ dotnet_naming_rule.type_parameters_rule.import_to_resharper = True
59
+ dotnet_naming_rule.type_parameters_rule.resharper_description = Type parameters
60
+ dotnet_naming_rule.type_parameters_rule.resharper_guid = 2c62818f-621b-4425-adc9-78611099bfcb
61
+ dotnet_naming_rule.type_parameters_rule.severity = warning
62
+ dotnet_naming_rule.type_parameters_rule.style = t_upper_camel_case_style
63
+ dotnet_naming_rule.type_parameters_rule.symbols = type_parameters_symbols
64
+ dotnet_naming_rule.unity_serialized_field_rule.import_to_resharper = True
65
+ dotnet_naming_rule.unity_serialized_field_rule.resharper_description = Unity serialized field
66
+ dotnet_naming_rule.unity_serialized_field_rule.resharper_guid = 5f0fdb63-c892-4d2c-9324-15c80b22a7ef
67
+ dotnet_naming_rule.unity_serialized_field_rule.severity = none
68
+ dotnet_naming_rule.unity_serialized_field_rule.style = lower_camel_case_style
69
+ dotnet_naming_rule.unity_serialized_field_rule.symbols = unity_serialized_field_symbols
70
+ dotnet_naming_style.i_upper_camel_case_style.capitalization = pascal_case
71
+ dotnet_naming_style.i_upper_camel_case_style.required_prefix = I
72
+ dotnet_naming_style.lower_camel_case_style.capitalization = camel_case
73
+ dotnet_naming_style.on_upper_camel_case_style.capitalization = pascal_case
74
+ dotnet_naming_style.on_upper_camel_case_style.required_prefix = On
75
+ dotnet_naming_style.t_upper_camel_case_style.capitalization = pascal_case
76
+ dotnet_naming_style.t_upper_camel_case_style.required_prefix = T
77
+ dotnet_naming_style.upper_camel_case_style.capitalization = pascal_case
78
+ dotnet_naming_symbols.event_symbols.applicable_accessibilities = *
79
+ dotnet_naming_symbols.event_symbols.applicable_kinds = event
80
+ dotnet_naming_symbols.event_symbols.resharper_applicable_kinds = event
81
+ dotnet_naming_symbols.event_symbols.resharper_required_modifiers = any
82
+ dotnet_naming_symbols.interfaces_symbols.applicable_accessibilities = *
83
+ dotnet_naming_symbols.interfaces_symbols.applicable_kinds = interface
84
+ dotnet_naming_symbols.interfaces_symbols.resharper_applicable_kinds = interface
85
+ dotnet_naming_symbols.interfaces_symbols.resharper_required_modifiers = any
86
+ dotnet_naming_symbols.local_constants_symbols.applicable_accessibilities = *
87
+ dotnet_naming_symbols.local_constants_symbols.applicable_kinds = local
88
+ dotnet_naming_symbols.local_constants_symbols.required_modifiers = const
89
+ dotnet_naming_symbols.local_constants_symbols.resharper_applicable_kinds = local_constant
90
+ dotnet_naming_symbols.local_constants_symbols.resharper_required_modifiers = any
91
+ dotnet_naming_symbols.public_fields_override_symbols.applicable_accessibilities = public
92
+ dotnet_naming_symbols.public_fields_override_symbols.applicable_kinds = field
93
+ dotnet_naming_symbols.public_fields_override_symbols.required_modifiers = const
94
+ dotnet_naming_symbols.public_fields_override_symbols_1.applicable_accessibilities = public
95
+ dotnet_naming_symbols.public_fields_override_symbols_1.applicable_kinds = field
96
+ dotnet_naming_symbols.public_fields_override_symbols_1.required_modifiers = readonly,static
97
+ dotnet_naming_symbols.public_fields_symbols.applicable_accessibilities = public
98
+ dotnet_naming_symbols.public_fields_symbols.applicable_kinds = field
99
+ dotnet_naming_symbols.public_fields_symbols.resharper_applicable_kinds = field,readonly_field
100
+ dotnet_naming_symbols.public_fields_symbols.resharper_required_modifiers = instance
101
+ dotnet_naming_symbols.public_static_fields_symbols.applicable_accessibilities = public
102
+ dotnet_naming_symbols.public_static_fields_symbols.applicable_kinds = field
103
+ dotnet_naming_symbols.public_static_fields_symbols.required_modifiers = static
104
+ dotnet_naming_symbols.public_static_fields_symbols.resharper_applicable_kinds = field
105
+ dotnet_naming_symbols.public_static_fields_symbols.resharper_required_modifiers = static
106
+ dotnet_naming_symbols.type_parameters_symbols.applicable_accessibilities = *
107
+ dotnet_naming_symbols.type_parameters_symbols.applicable_kinds = type_parameter
108
+ dotnet_naming_symbols.type_parameters_symbols.resharper_applicable_kinds = type_parameter
109
+ dotnet_naming_symbols.type_parameters_symbols.resharper_required_modifiers = any
110
+ dotnet_naming_symbols.unity_serialized_field_symbols.applicable_accessibilities = *
111
+ dotnet_naming_symbols.unity_serialized_field_symbols.applicable_kinds =
112
+ dotnet_naming_symbols.unity_serialized_field_symbols.resharper_applicable_kinds = unity_serialised_field
113
+ dotnet_naming_symbols.unity_serialized_field_symbols.resharper_required_modifiers = instance
114
+ dotnet_style_parentheses_in_arithmetic_binary_operators = never_if_unnecessary:none
115
+ dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:none
116
+ dotnet_style_parentheses_in_relational_binary_operators = never_if_unnecessary:none
117
+ dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
118
+ dotnet_style_predefined_type_for_member_access = true:suggestion
119
+ dotnet_style_qualification_for_event = false:suggestion
120
+ dotnet_style_qualification_for_field = false:suggestion
121
+ dotnet_style_qualification_for_method = false:suggestion
122
+ dotnet_style_qualification_for_property = false:suggestion
123
+ dotnet_style_require_accessibility_modifiers = for_non_interface_members:suggestion
124
+
125
+ # ReSharper properties
126
+ resharper_autodetect_indent_settings = true
127
+ resharper_braces_redundant = true
128
+ resharper_csharp_wrap_lines = false
129
+ resharper_formatter_off_tag = @formatter:off
130
+ resharper_formatter_on_tag = @formatter:on
131
+ resharper_formatter_tags_enabled = true
132
+ resharper_indent_preprocessor_directives = normal
133
+ resharper_keep_existing_attribute_arrangement = true
134
+ resharper_place_attribute_on_same_line = false
135
+ resharper_show_autodetect_configure_formatting_tip = false
136
+ resharper_use_indent_from_vs = false
137
+
138
+ # ReSharper inspection severities
139
+ resharper_arrange_redundant_parentheses_highlighting = hint
140
+ resharper_arrange_this_qualifier_highlighting = hint
141
+ resharper_arrange_trailing_comma_in_multiline_lists_highlighting = none
142
+ resharper_arrange_type_member_modifiers_highlighting = hint
143
+ resharper_arrange_type_modifiers_highlighting = hint
144
+ resharper_built_in_type_reference_style_for_member_access_highlighting = hint
145
+ resharper_built_in_type_reference_style_highlighting = hint
146
+ resharper_mvc_action_not_resolved_highlighting = warning
147
+ resharper_mvc_area_not_resolved_highlighting = warning
148
+ resharper_mvc_controller_not_resolved_highlighting = warning
149
+ resharper_mvc_masterpage_not_resolved_highlighting = warning
150
+ resharper_mvc_partial_view_not_resolved_highlighting = warning
151
+ resharper_mvc_template_not_resolved_highlighting = warning
152
+ resharper_mvc_view_component_not_resolved_highlighting = warning
153
+ resharper_mvc_view_component_view_not_resolved_highlighting = warning
154
+ resharper_mvc_view_not_resolved_highlighting = warning
155
+ resharper_prefer_concrete_value_over_default_highlighting = none
156
+ resharper_razor_assembly_not_resolved_highlighting = warning
157
+ resharper_redundant_base_qualifier_highlighting = warning
158
+ resharper_suggest_var_or_type_built_in_types_highlighting = hint
159
+ resharper_suggest_var_or_type_elsewhere_highlighting = hint
160
+ resharper_suggest_var_or_type_simple_types_highlighting = hint
161
+ resharper_web_config_module_not_resolved_highlighting = warning
162
+ resharper_web_config_type_not_resolved_highlighting = warning
163
+ resharper_web_config_wrong_module_highlighting = warning
164
+
165
+ [{*.har,*.inputactions,*.jsb2,*.jsb3,*.json,*.jsonc,*.postman_collection,*.postman_collection.json,*.postman_environment,*.postman_environment.json,.babelrc,.eslintrc,.prettierrc,.stylelintrc,.ws-context,jest.config}]
166
+ indent_style = space
167
+ indent_size = 2
168
+
169
+ [{*.yaml,*.yml}]
170
+ indent_style = space
171
+ indent_size = 2
172
+
173
+ [*.asmdef]
174
+ indent_style = space
175
+ indent_size = 2
176
+
177
+ [*.asmref]
178
+ indent_style = space
179
+ indent_size = 2
180
+
181
+ [*.{appxmanifest,asax,ascx,aspx,axaml,blockshader,build,c,c++,c++m,cc,ccm,cginc,compute,cp,cpp,cppm,cs,cshtml,cu,cuh,cxx,cxxm,dtd,fs,fsi,fsscript,fsx,fx,fxh,h,h++,hh,hlsl,hlsli,hlslinc,hp,hpp,hxx,icc,inc,inl,ino,ipp,ixx,master,ml,mli,mpp,mq4,mq5,mqh,mxx,nuspec,paml,razor,resw,resx,shader,shaderFoundry,skin,tcc,tpp,urtshader,usf,ush,uxml,vb,xaml,xamlx,xoml,xsd}]
182
+ indent_style = space
183
+ indent_size = 4
184
+ tab_width = 4
@@ -0,0 +1,22 @@
1
+ repos:
2
+ - repo: local
3
+ hooks:
4
+ - id: dotnet-tool-restore
5
+ name: Install .NET tools
6
+ entry: dotnet tool restore
7
+ language: system
8
+ always_run: true
9
+ pass_filenames: false
10
+ stages:
11
+ - pre-commit
12
+ - pre-push
13
+ - post-checkout
14
+ - post-rewrite
15
+ description: Install the .NET tools listed at .config/dotnet-tools.json.
16
+ - id: csharpier
17
+ name: Run CSharpier on C# files
18
+ entry: dotnet tool run dotnet-csharpier
19
+ language: system
20
+ types:
21
+ - c#
22
+ description: CSharpier is an opinionated C# formatter inspired by Prettier.
package/README.md CHANGED
@@ -171,4 +171,8 @@ Assert.AreEqual(myCoolGameObject, nearestNeighbors[0]);
171
171
  ```
172
172
 
173
173
  ## Note
174
- All spatial trees expect the positional data to be *immutable*. It is very important that the positions do not change. If they do, you will need to reconstruct the tree.
174
+ All spatial trees expect the positional data to be *immutable*. It is very important that the positions do not change. If they do, you will need to reconstruct the tree.
175
+
176
+ ## Contributing
177
+
178
+ This project uses [CSharpier](https://csharpier.com/) with the default configuration to enable an enforced, consistent style. If you would like to contribute, recommendation is to ensure that changed files are ran through CSharpier prior to merge. This can be done automatically through editor plugins, or, minimally, by installing a [pre-commit hook](https://pre-commit.com/#3-install-the-git-hook-scripts).
@@ -125,7 +125,11 @@
125
125
  {
126
126
  if (dictionary is ConcurrentDictionary<K, V> concurrentDictionary)
127
127
  {
128
- return concurrentDictionary.AddOrUpdate(key, creator, (_, existing) => existing);
128
+ return concurrentDictionary.AddOrUpdate(
129
+ key,
130
+ creator,
131
+ (_, existingValue) => existingValue
132
+ );
129
133
  }
130
134
 
131
135
  if (dictionary.TryGetValue(key, out V existing))
@@ -206,6 +210,14 @@
206
210
  return new Dictionary<K, V>(dictionary);
207
211
  }
208
212
 
213
+ public static Dictionary<K, V> ToDictionary<K, V>(
214
+ this IReadOnlyDictionary<K, V> dictionary,
215
+ IEqualityComparer<K> comparer
216
+ )
217
+ {
218
+ return new Dictionary<K, V>(dictionary, comparer);
219
+ }
220
+
209
221
  public static Dictionary<K, V> ToDictionary<K, V>(
210
222
  this IEnumerable<KeyValuePair<K, V>> prettyMuchADictionary
211
223
  )
@@ -213,6 +225,14 @@
213
225
  return prettyMuchADictionary.ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
214
226
  }
215
227
 
228
+ public static Dictionary<K, V> ToDictionary<K, V>(
229
+ this IEnumerable<KeyValuePair<K, V>> prettyMuchADictionary,
230
+ IEqualityComparer<K> comparer
231
+ )
232
+ {
233
+ return prettyMuchADictionary.ToDictionary(kvp => kvp.Key, kvp => kvp.Value, comparer);
234
+ }
235
+
216
236
  public static Dictionary<K, V> ToDictionary<K, V>(
217
237
  this IEnumerable<(K, V)> prettyMuchADictionary
218
238
  )
@@ -220,6 +240,14 @@
220
240
  return prettyMuchADictionary.ToDictionary(kvp => kvp.Item1, kvp => kvp.Item2);
221
241
  }
222
242
 
243
+ public static Dictionary<K, V> ToDictionary<K, V>(
244
+ this IEnumerable<(K, V)> prettyMuchADictionary,
245
+ IEqualityComparer<K> comparer
246
+ )
247
+ {
248
+ return prettyMuchADictionary.ToDictionary(kvp => kvp.Item1, kvp => kvp.Item2, comparer);
249
+ }
250
+
223
251
  public static bool ContentEquals<K, V>(
224
252
  this IReadOnlyDictionary<K, V> dictionary,
225
253
  IReadOnlyDictionary<K, V> other
@@ -0,0 +1,28 @@
1
+ namespace UnityHelpers.Core.Serialization.JsonConverters
2
+ {
3
+ using System;
4
+ using System.Text.Json;
5
+ using System.Text.Json.Serialization;
6
+
7
+ public sealed class TypeConverter : JsonConverter<Type>
8
+ {
9
+ public static readonly TypeConverter Instance = new();
10
+
11
+ private TypeConverter() { }
12
+
13
+ public override Type Read(
14
+ ref Utf8JsonReader reader,
15
+ Type typeToConvert,
16
+ JsonSerializerOptions options
17
+ )
18
+ {
19
+ string typeName = reader.GetString();
20
+ return string.IsNullOrWhiteSpace(typeName) ? null : Type.GetType(typeName);
21
+ }
22
+
23
+ public override void Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options)
24
+ {
25
+ writer.WriteStringValue(value?.AssemblyQualifiedName);
26
+ }
27
+ }
28
+ }
@@ -0,0 +1,3 @@
1
+ fileFormatVersion: 2
2
+ guid: ffebfa399370464baa7e9d9065db60f5
3
+ timeCreated: 1743566193
@@ -9,6 +9,7 @@
9
9
  using System.Text.Json.Serialization;
10
10
  using Extension;
11
11
  using JsonConverters;
12
+ using TypeConverter = JsonConverters.TypeConverter;
12
13
 
13
14
  internal static class SerializerEncoding
14
15
  {
@@ -31,6 +32,7 @@
31
32
  new JsonStringEnumConverter(),
32
33
  Vector3Converter.Instance,
33
34
  Vector2Converter.Instance,
35
+ TypeConverter.Instance,
34
36
  },
35
37
  };
36
38
 
@@ -46,6 +48,7 @@
46
48
  new JsonStringEnumConverter(),
47
49
  Vector3Converter.Instance,
48
50
  Vector2Converter.Instance,
51
+ TypeConverter.Instance,
49
52
  },
50
53
  WriteIndented = true,
51
54
  };
@@ -52,10 +52,7 @@
52
52
  return;
53
53
  }
54
54
 
55
- while (Interlocked.CompareExchange(ref _active, 0, _active) != 0)
56
- {
57
- // Spin
58
- }
55
+ Interlocked.Exchange(ref _active, 0);
59
56
 
60
57
  if (disposing)
61
58
  {
@@ -22,6 +22,8 @@
22
22
  public Dictionary<string, bool> DictionaryProperty { get; set; } = new();
23
23
 
24
24
  public List<int> ListProperty { get; set; } = new();
25
+
26
+ public List<Type> TypeProperties { get; set; } = new();
25
27
  }
26
28
 
27
29
  public class JsonSerializationTest
@@ -35,6 +37,12 @@
35
37
  field = Guid.NewGuid().ToString(),
36
38
  Property = random.Next(),
37
39
  NamedProperty = random.NextFloat(),
40
+ TypeProperties = new List<Type>()
41
+ {
42
+ typeof(int),
43
+ typeof(Serializer),
44
+ typeof(TestDataObject),
45
+ },
38
46
  };
39
47
 
40
48
  int dictionaryProperties = random.Next(4, 10);
@@ -79,6 +87,7 @@
79
87
  input.ListProperty.SequenceEqual(deserialized.ListProperty),
80
88
  $"Unexpected {nameof(deserialized.ListProperty)}! JSON: {json}"
81
89
  );
90
+ Assert.That(input.TypeProperties, Is.EquivalentTo(deserialized.TypeProperties));
82
91
  }
83
92
  }
84
93
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "com.wallstop-studios.unity-helpers",
3
- "version": "2.0.0-rc47",
3
+ "version": "2.0.0-rc49",
4
4
  "displayName": "Unity Helpers",
5
5
  "description": "Various Unity Helper Library",
6
6
  "dependencies": {},