Skip to content

Commit 297a838

Browse files
authored
Merge pull request #129 from rsdn/feature/nullable_v3
Nullable reference types support
2 parents 1b5de01 + cf13a78 commit 297a838

396 files changed

Lines changed: 7717 additions & 9530 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.editorconfig

Lines changed: 195 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,200 @@ end_of_line = crlf
66
indent_style = tab
77
trim_trailing_whitespace = true
88

9+
### Compiler diagnostic ###
10+
11+
# Nullability as error
12+
dotnet_diagnostic.cs8600.severity=error
13+
dotnet_diagnostic.cs8601.severity=error
14+
dotnet_diagnostic.cs8602.severity=error
15+
dotnet_diagnostic.cs8603.severity=error
16+
dotnet_diagnostic.cs8604.severity=error
17+
dotnet_diagnostic.cs8605.severity=error
18+
dotnet_diagnostic.cs8606.severity=error
19+
dotnet_diagnostic.cs8607.severity=error
20+
dotnet_diagnostic.cs8608.severity=error
21+
dotnet_diagnostic.cs8609.severity=error
22+
dotnet_diagnostic.cs8610.severity=error
23+
dotnet_diagnostic.cs8611.severity=error
24+
dotnet_diagnostic.cs8612.severity=error
25+
dotnet_diagnostic.cs8613.severity=error
26+
dotnet_diagnostic.cs8614.severity=error
27+
dotnet_diagnostic.cs8615.severity=error
28+
dotnet_diagnostic.cs8616.severity=error
29+
dotnet_diagnostic.cs8617.severity=error
30+
dotnet_diagnostic.cs8618.severity=error
31+
dotnet_diagnostic.cs8619.severity=error
32+
dotnet_diagnostic.cs8620.severity=error
33+
dotnet_diagnostic.cs8621.severity=error
34+
dotnet_diagnostic.cs8622.severity=error
35+
dotnet_diagnostic.cs8623.severity=error
36+
dotnet_diagnostic.cs8624.severity=error
37+
dotnet_diagnostic.cs8625.severity=error
38+
dotnet_diagnostic.cs8626.severity=error
39+
dotnet_diagnostic.cs8627.severity=error
40+
dotnet_diagnostic.cs8628.severity=error
41+
dotnet_diagnostic.cs8629.severity=error
42+
dotnet_diagnostic.cs8630.severity=error
43+
dotnet_diagnostic.cs8631.severity=error
44+
dotnet_diagnostic.cs8632.severity=error
45+
dotnet_diagnostic.cs8633.severity=error
46+
dotnet_diagnostic.cs8634.severity=error
47+
dotnet_diagnostic.cs8635.severity=error
48+
dotnet_diagnostic.cs8636.severity=error
49+
dotnet_diagnostic.cs8637.severity=error
50+
dotnet_diagnostic.cs8638.severity=error
51+
dotnet_diagnostic.cs8639.severity=error
52+
dotnet_diagnostic.cs8640.severity=error
53+
dotnet_diagnostic.cs8641.severity=error
54+
dotnet_diagnostic.cs8642.severity=error
55+
dotnet_diagnostic.cs8643.severity=error
56+
dotnet_diagnostic.cs8644.severity=error
57+
dotnet_diagnostic.cs8645.severity=error
58+
dotnet_diagnostic.cs8646.severity=error
59+
dotnet_diagnostic.cs8647.severity=error
60+
dotnet_diagnostic.cs8648.severity=error
61+
dotnet_diagnostic.cs8649.severity=error
62+
dotnet_diagnostic.cs8650.severity=error
63+
dotnet_diagnostic.cs8651.severity=error
64+
dotnet_diagnostic.cs8652.severity=error
65+
dotnet_diagnostic.cs8653.severity=error
66+
dotnet_diagnostic.cs8654.severity=error
67+
dotnet_diagnostic.cs8655.severity=error
68+
dotnet_diagnostic.cs8656.severity=error
69+
dotnet_diagnostic.cs8667.severity=error
70+
dotnet_diagnostic.cs8714.severity=error
71+
72+
### IDE Diagnostic ###
73+
74+
# Indexing can be simplified
75+
dotnet_diagnostic.ide0056.severity=none
76+
dotnet_diagnostic.ide0057.severity=none
77+
78+
# 'using' statement can be simplified
79+
dotnet_diagnostic.ide0063.severity=none
80+
81+
# Remove unnecessary suppression
82+
dotnet_diagnostic.ide0079.severity=none
83+
dotnet_remove_unnecessary_suppression_exclusions=ide0079
84+
85+
### Naming ###
86+
87+
# avoid this. unless absolutely necessary
88+
dotnet_style_qualification_for_field = false:suggestion
89+
dotnet_style_qualification_for_property = false:suggestion
90+
dotnet_style_qualification_for_method = false:suggestion
91+
dotnet_style_qualification_for_event = false:suggestion
92+
93+
### C# Style ###
94+
95+
csharp_style_var_for_built_in_types = true:suggestion
96+
csharp_style_var_when_type_is_apparent = true:suggestion
97+
csharp_style_var_elsewhere = true:suggestion
98+
csharp_space_after_cast=false
99+
100+
### .NET Style ###
101+
102+
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
103+
dotnet_style_predefined_type_for_member_access = true:suggestion
104+
dotnet_naming_rule.private_constants_rule.severity=warning
105+
dotnet_naming_rule.private_constants_rule.style=lower_camel_case_style
106+
dotnet_naming_rule.private_constants_rule.symbols=private_constants_symbols
107+
dotnet_naming_rule.private_static_readonly_rule.severity=warning
108+
dotnet_naming_rule.private_static_readonly_rule.style=lower_camel_case_style
109+
dotnet_naming_rule.private_static_readonly_rule.symbols=private_static_readonly_symbols
110+
dotnet_naming_style.lower_camel_case_style.capitalization=camel_case
111+
dotnet_naming_style.lower_camel_case_style.required_prefix=_
112+
dotnet_naming_symbols.private_constants_symbols.applicable_accessibilities=private
113+
dotnet_naming_symbols.private_constants_symbols.applicable_kinds=field
114+
dotnet_naming_symbols.private_constants_symbols.required_modifiers=const
115+
dotnet_naming_symbols.private_static_readonly_symbols.applicable_accessibilities=private
116+
dotnet_naming_symbols.private_static_readonly_symbols.applicable_kinds=field
117+
dotnet_naming_symbols.private_static_readonly_symbols.required_modifiers=static,readonly
118+
dotnet_separate_import_directive_groups=true
119+
dotnet_style_parentheses_in_arithmetic_binary_operators=never_if_unnecessary:suggestion
120+
dotnet_style_parentheses_in_other_binary_operators=never_if_unnecessary:suggestion
121+
dotnet_style_parentheses_in_relational_binary_operators=never_if_unnecessary:suggestion
122+
dotnet_style_require_accessibility_modifiers=for_non_interface_members:suggestion
123+
124+
### ReSharper ###
125+
resharper_align_multiline_binary_expressions_chain=false
126+
resharper_apply_auto_detected_rules=false
127+
resharper_blank_lines_around_auto_property=0
128+
resharper_blank_lines_around_property=0
129+
resharper_braces_for_dowhile=not_required
130+
resharper_braces_for_fixed=not_required
131+
resharper_braces_for_lock=not_required
132+
resharper_braces_for_using=not_required
133+
resharper_constructor_or_destructor_body=expression_body
134+
resharper_csharp_blank_lines_inside_region=0
135+
resharper_csharp_empty_block_style=together_same_line
136+
resharper_csharp_keep_blank_lines_in_code=1
137+
resharper_csharp_keep_blank_lines_in_declarations=1
138+
resharper_csharp_wrap_after_declaration_lpar=true
139+
resharper_csharp_wrap_after_invocation_lpar=true
140+
resharper_csharp_wrap_before_binary_opsign=true
141+
resharper_csharp_wrap_before_first_type_parameter_constraint=true
142+
resharper_csharp_wrap_parameters_style=chop_if_long
143+
resharper_int_align_declaration_names=true
144+
resharper_keep_existing_expr_member_arrangement=false
145+
resharper_keep_existing_initializer_arrangement=false
146+
resharper_keep_existing_linebreaks=false
147+
resharper_local_function_body=expression_body
148+
resharper_method_or_operator_body=expression_body
149+
resharper_old_engine=true
150+
resharper_parentheses_non_obvious_operations=none, bitwise, bitwise_inclusive_or, range, bitwise_exclusive_or, shift, bitwise_and
151+
resharper_place_attribute_on_same_line=false
152+
resharper_place_simple_accessor_on_single_line=false
153+
resharper_space_after_cast=false
154+
resharper_space_within_single_line_array_initializer_braces=true
155+
resharper_wrap_text=false
156+
resharper_xmldoc_attribute_style=on_single_line
157+
resharper_xmldoc_blank_line_after_pi=false
158+
resharper_xmldoc_indent_child_elements=ZeroIndent
159+
resharper_xmldoc_indent_text=ZeroIndent
160+
resharper_xmldoc_linebreaks_inside_tags_for_elements_longer_than=100
161+
resharper_xmldoc_linebreaks_inside_tags_for_elements_with_child_elements=false
162+
resharper_xmldoc_pi_attributes_indent=single_indent
163+
resharper_xmldoc_pi_attribute_style=on_single_line
164+
resharper_xmldoc_space_before_self_closing=false
165+
resharper_xmldoc_wrap_around_elements=false
166+
resharper_xmldoc_wrap_tags_and_pi=false
167+
168+
# ReSharper inspection severities
169+
resharper_arguments_style_literal_highlighting=none
170+
resharper_arrange_constructor_or_destructor_body_highlighting=suggestion
171+
resharper_arrange_local_function_body_highlighting=suggestion
172+
resharper_arrange_method_or_operator_body_highlighting=suggestion
173+
resharper_arrange_redundant_parentheses_highlighting=hint
174+
resharper_arrange_this_qualifier_highlighting=hint
175+
resharper_built_in_type_reference_style_for_member_access_highlighting=hint
176+
resharper_built_in_type_reference_style_highlighting=hint
177+
resharper_convert_closure_to_method_group_highlighting=hint
178+
resharper_convert_if_statement_to_return_statement_highlighting=none
179+
resharper_convert_to_auto_property_with_private_setter_highlighting=none
180+
resharper_convert_to_lambda_expression_when_possible_highlighting=suggestion
181+
resharper_convert_to_using_declaration_highlighting=none
182+
resharper_field_can_be_made_read_only_global_highlighting=warning
183+
resharper_invert_if_highlighting=none
184+
resharper_invocation_is_skipped_highlighting=none
185+
resharper_join_null_check_with_usage_highlighting=hint
186+
resharper_local_suppression_highlighting=none
187+
resharper_loop_can_be_converted_to_query_highlighting=none
188+
resharper_member_can_be_private_global_highlighting=warning
189+
resharper_missing_suppression_justification_highlighting=none
190+
resharper_parameter_only_used_for_precondition_check_local_highlighting=none
191+
resharper_redundant_argument_default_value_highlighting=none
192+
resharper_redundant_attribute_usage_property_highlighting=hint
193+
resharper_redundant_base_qualifier_highlighting=warning
194+
resharper_redundant_default_member_initializer_highlighting=none
195+
resharper_return_type_can_be_enumerable_global_highlighting=none
196+
resharper_suggest_base_type_for_parameter_highlighting=none
197+
resharper_suggest_var_or_type_built_in_types_highlighting=hint
198+
resharper_switch_expression_handles_some_known_enum_values_with_exception_in_default_highlighting=none
199+
resharper_tail_recursive_call_highlighting=warning
200+
resharper_unused_parameter_local_highlighting=hint
201+
resharper_use_index_from_end_expression_highlighting=none
202+
resharper_use_nameof_expression_highlighting=warning
203+
9204
[*.ttinclude]
10205
insert_final_newline = false

Build/Build.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<TargetFramework>net472</TargetFramework>
44
</PropertyGroup>

Build/JetBrains.Annotations.cs

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,13 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121
SOFTWARE. */
2222

2323
using System;
24+
2425
// ReSharper disable InheritdocConsiderUsage
2526

27+
#pragma warning disable IDE0079
2628
#pragma warning disable 1591
29+
#pragma warning disable CS8618
30+
#pragma warning disable CS0618
2731
// ReSharper disable UnusedMember.Global
2832
// ReSharper disable MemberCanBePrivate.Global
2933
// ReSharper disable UnusedAutoPropertyAccessor.Global
@@ -49,6 +53,7 @@ namespace JetBrains.Annotations
4953
AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property |
5054
AttributeTargets.Delegate | AttributeTargets.Field | AttributeTargets.Event |
5155
AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.GenericParameter)]
56+
[Obsolete("Use C# NRT markup")]
5257
internal sealed class CanBeNullAttribute : Attribute { }
5358

5459
/// <summary>
@@ -63,6 +68,7 @@ internal sealed class CanBeNullAttribute : Attribute { }
6368
AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property |
6469
AttributeTargets.Delegate | AttributeTargets.Field | AttributeTargets.Event |
6570
AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.GenericParameter)]
71+
[Obsolete("Use C# NRT markup")]
6672
internal sealed class NotNullAttribute : Attribute { }
6773

6874
/// <summary>
@@ -82,6 +88,7 @@ internal sealed class NotNullAttribute : Attribute { }
8288
[AttributeUsage(
8389
AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property |
8490
AttributeTargets.Delegate | AttributeTargets.Field)]
91+
[Obsolete("Use C# NRT markup")]
8592
internal sealed class ItemNotNullAttribute : Attribute { }
8693

8794
/// <summary>
@@ -102,6 +109,7 @@ internal sealed class ItemNotNullAttribute : Attribute { }
102109
[AttributeUsage(
103110
AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property |
104111
AttributeTargets.Delegate | AttributeTargets.Field)]
112+
[Obsolete("Use C# NRT markup")]
105113
internal sealed class ItemCanBeNullAttribute : Attribute { }
106114

107115
/// <summary>
@@ -293,7 +301,7 @@ public NotifyPropertyChangedInvocatorAttribute([NotNull] string parameterName)
293301
ParameterName = parameterName;
294302
}
295303

296-
[CanBeNull] public string ParameterName { get; }
304+
public string? ParameterName { get; }
297305
}
298306

299307
/// <summary>
@@ -534,7 +542,7 @@ public PublicAPIAttribute([NotNull] string comment)
534542
Comment = comment;
535543
}
536544

537-
[CanBeNull] public string Comment { get; }
545+
public string? Comment { get; }
538546
}
539547

540548
/// <summary>
@@ -580,7 +588,7 @@ public MustUseReturnValueAttribute([NotNull] string justification)
580588
Justification = justification;
581589
}
582590

583-
[CanBeNull] public string Justification { get; }
591+
public string? Justification { get; }
584592
}
585593

586594
/// <summary>
@@ -617,7 +625,7 @@ public PathReferenceAttribute([NotNull, PathReference] string basePath)
617625
BasePath = basePath;
618626
}
619627

620-
[CanBeNull] public string BasePath { get; }
628+
public string? BasePath { get; }
621629
}
622630

623631
/// <summary>
@@ -681,7 +689,7 @@ internal sealed class MacroAttribute : Attribute
681689
/// Allows specifying a macro that will be executed for a <see cref="SourceTemplateAttribute">source template</see>
682690
/// parameter when the template is expanded.
683691
/// </summary>
684-
[CanBeNull] public string Expression { get; set; }
692+
public string? Expression { get; set; }
685693

686694
/// <summary>
687695
/// Allows specifying which occurrence of the target parameter becomes editable when the template is deployed.
@@ -697,7 +705,7 @@ internal sealed class MacroAttribute : Attribute
697705
/// Identifies the target parameter of a <see cref="SourceTemplateAttribute">source template</see> if the
698706
/// <see cref="MacroAttribute"/> is applied on a template method.
699707
/// </summary>
700-
[CanBeNull] public string Target { get; set; }
708+
public string? Target { get; set; }
701709
}
702710

703711
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = true)]
@@ -782,7 +790,7 @@ public AspMvcActionAttribute([NotNull] string anonymousProperty)
782790
AnonymousProperty = anonymousProperty;
783791
}
784792

785-
[CanBeNull] public string AnonymousProperty { get; }
793+
public string? AnonymousProperty { get; }
786794
}
787795

788796
/// <summary>
@@ -800,7 +808,7 @@ public AspMvcAreaAttribute([NotNull] string anonymousProperty)
800808
AnonymousProperty = anonymousProperty;
801809
}
802810

803-
[CanBeNull] public string AnonymousProperty { get; }
811+
public string? AnonymousProperty { get; }
804812
}
805813

806814
/// <summary>
@@ -819,7 +827,7 @@ public AspMvcControllerAttribute([NotNull] string anonymousProperty)
819827
AnonymousProperty = anonymousProperty;
820828
}
821829

822-
[CanBeNull] public string AnonymousProperty { get; }
830+
public string? AnonymousProperty { get; }
823831
}
824832

825833
/// <summary>
@@ -922,7 +930,7 @@ public HtmlElementAttributesAttribute([NotNull] string name)
922930
Name = name;
923931
}
924932

925-
[CanBeNull] public string Name { get; }
933+
public string? Name { get; }
926934
}
927935

928936
[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property)]
@@ -1216,7 +1224,7 @@ public RazorPageBaseTypeAttribute([NotNull] string baseType, string pageName)
12161224
}
12171225

12181226
[NotNull] public string BaseType { get; }
1219-
[CanBeNull] public string PageName { get; }
1227+
public string? PageName { get; }
12201228
}
12211229

12221230
[AttributeUsage(AttributeTargets.Method)]
@@ -1233,4 +1241,4 @@ internal sealed class RazorWriteMethodAttribute : Attribute { }
12331241

12341242
[AttributeUsage(AttributeTargets.Parameter)]
12351243
internal sealed class RazorWriteMethodParameterAttribute : Attribute { }
1236-
}
1244+
}

Build/Props/CodeJam.Default.props

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@
77
<DelaySign>False</DelaySign>
88
<AssemblyOriginatorKeyFile>..\Build\CodeJam.snk</AssemblyOriginatorKeyFile>
99

10+
<LangVersion>9.0</LangVersion>
11+
<Nullable>enable</Nullable>
12+
<!-- <AnalysisLevel>latest</AnalysisLevel> -->
13+
<!-- <EnableNETAnalyzers>true</EnableNETAnalyzers> -->
14+
<!-- <AnalysisMode>AllEnabledByDefault</AnalysisMode> -->
15+
1016
<Version>4.0.0.0</Version>
1117
<PackageVersion>4.0.0-beta1</PackageVersion>
1218
<PackageOutputPath>..\_Results</PackageOutputPath>

Build/T4/Autogenerated.ttinclude

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
// the code is regenerated.
1313
// </auto-generated>
1414
//------------------------------------------------------------------------------
15+
16+
#nullable enable
1517
<#+
1618
private string EscapeXmlDocString(string xmlDocText) =>
1719
new System.Xml.Linq.XText(xmlDocText).ToString();

Build/T4/Transform.ttinclude

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@
114114
: pattern;
115115

116116
pattern = replaceInfo.WholeLineMode
117-
? @".*" + pattern + @".*[\r\n]+"
117+
? @".*" + pattern + @".*[\r\n]+"
118118
: pattern;
119119

120120
return pattern;

CodeJam.Blocks.Tests/CodeJam.Blocks.Tests.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
<PackageReference Include="NUnit3TestAdapter" Version="3.17.0" />
2222
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.0" />
2323
</ItemGroup>
24+
<ItemGroup>
25+
<Compile Include="..\CodeJam.Main.Tests\NAssert.cs" Link="NAssert.cs" />
26+
</ItemGroup>
2427
<!-- #endregion -->
2528

2629
<ItemGroup>

0 commit comments

Comments
 (0)