Skip to content

Commit ef31658

Browse files
committed
[Xamarin.Android.Tools.AndroidSdk] Nullable Reference Type support (#84)
Annotate `Xamarin.Android.Tools.AndroidSdk.dll` to support C#8 [Nullable Reference Types][0] Additionally, add Visual Studio Code support and fix the Azure Pipelines build. [0]: https://docs.microsoft.com/en-us/dotnet/csharp/nullable-references
1 parent b8efdae commit ef31658

24 files changed

+657
-175
lines changed

.editorconfig

+199
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,199 @@
1+
###############################
2+
# Core EditorConfig Options #
3+
###############################
4+
5+
root = true
6+
7+
# All files
8+
[*]
9+
charset = utf-8
10+
trim_trailing_whitespace = true
11+
12+
# MSBuild
13+
[*.{csproj,proj,projitems,shproj,fsproj,targets,props}]
14+
indent_style = space
15+
indent_size = 2
16+
17+
# XML config files
18+
[*.{xml,axml,xaml,config,nuspec,resx}]
19+
indent_style = space
20+
indent_size = 2
21+
22+
# JSON files
23+
[*.json]
24+
indent_style = space
25+
indent_size = 2
26+
27+
# F# files
28+
[*.{fs, fsx, fsi}]
29+
indent_style = space
30+
indent_size = 4
31+
32+
# Code files
33+
[*.{cs,csx,vb,vbx}]
34+
insert_final_newline = true
35+
indent_style = tab
36+
tab_width = 8
37+
indent_size = 8
38+
max_line_length = 180
39+
40+
###############################
41+
# .NET Coding Conventions #
42+
###############################
43+
44+
[*.{cs,vb}]
45+
# Organize usings
46+
dotnet_sort_system_directives_first = true
47+
dotnet_separate_import_directive_groups = false
48+
49+
# Avoid "this." and "Me." if not necessary
50+
dotnet_style_qualification_for_field = false:suggestion
51+
dotnet_style_qualification_for_property = false:suggestion
52+
dotnet_style_qualification_for_method = false:suggestion
53+
dotnet_style_qualification_for_event = false:suggestion
54+
55+
# Use language keywords instead of framework type names for type references
56+
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
57+
dotnet_style_predefined_type_for_member_access = true:suggestion
58+
59+
# Suggest more modern language features when available
60+
dotnet_style_object_initializer = true:suggestion
61+
dotnet_style_collection_initializer = true:suggestion
62+
dotnet_style_coalesce_expression = true:suggestion
63+
dotnet_style_null_propagation = true:suggestion
64+
dotnet_style_explicit_tuple_names = true:suggestion
65+
66+
# Parentheses preferences
67+
dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:silent
68+
dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:silent
69+
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:silent
70+
dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent
71+
72+
# Avoid redundant accessibility modifiers when they're default
73+
dotnet_style_require_accessibility_modifiers = omit_if_default:suggestion
74+
dotnet_style_readonly_field = true:suggestion
75+
76+
# Expression-level preferences
77+
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
78+
dotnet_style_prefer_inferred_tuple_names = true:suggestion
79+
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
80+
dotnet_style_prefer_auto_properties = true:silent
81+
dotnet_style_prefer_conditional_expression_over_assignment = true:silent
82+
dotnet_style_prefer_conditional_expression_over_return = true:silent
83+
84+
###############################
85+
# Naming Conventions #
86+
###############################
87+
88+
# Style Definitions
89+
dotnet_naming_style.pascal_case_style.capitalization = pascal_case
90+
91+
dotnet_naming_style.underline_separator.word_separator = _
92+
dotnet_naming_style.underline_separator.capitalization = all_lower
93+
94+
# Symbol Definitions
95+
dotnet_naming_symbols.parameters.applicable_kinds = parameter
96+
dotnet_naming_symbols.parameters.applicable_accessibilities = *
97+
98+
dotnet_naming_symbols.fields.applicable_kinds = field
99+
100+
dotnet_naming_symbols.constant_fields.applicable_kinds = field
101+
dotnet_naming_symbols.constant_fields.applicable_accessibilities = *
102+
dotnet_naming_symbols.constant_fields.required_modifiers = const
103+
104+
# Use CamelCase for parameters
105+
dotnet_naming_rule.method_parameters_should_be_camel_case.severity = suggestion
106+
dotnet_naming_rule.method_parameters_should_be_camel_case.symbols = parameters
107+
dotnet_naming_rule.method_parameters_should_be_camel_case.style = camel_case
108+
109+
# Use PascalCase for constant fields
110+
dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = suggestion
111+
dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols = constant_fields
112+
dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style
113+
114+
# Use underline separator for instance fields
115+
dotnet_naming_rule.fields_should_be_underline_separator.severity = suggestion
116+
dotnet_naming_rule.fields_should_be_underline_separator.symbols = fields
117+
dotnet_naming_rule.fields_should_be_underline_separator.style = underline_separator
118+
119+
120+
###############################
121+
# C# Code Style Rules #
122+
###############################
123+
124+
[*.cs]
125+
# var preferences
126+
csharp_style_var_for_built_in_types = true:silent
127+
csharp_style_var_when_type_is_apparent = true:silent
128+
csharp_style_var_elsewhere = true:silent
129+
130+
# Expression-bodied members
131+
csharp_style_expression_bodied_methods = false:silent
132+
csharp_style_expression_bodied_constructors = false:silent
133+
csharp_style_expression_bodied_operators = false:silent
134+
csharp_style_expression_bodied_properties = true:silent
135+
csharp_style_expression_bodied_indexers = true:silent
136+
csharp_style_expression_bodied_accessors = true:silent
137+
138+
# Pattern-matching preferences
139+
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
140+
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
141+
142+
# Null-checking preferences
143+
csharp_style_throw_expression = true:suggestion
144+
csharp_style_conditional_delegate_call = true:suggestion
145+
146+
# Modifier preferences
147+
csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:suggestion
148+
149+
# Expression-level preferences
150+
csharp_prefer_braces = true:silent
151+
csharp_style_deconstructed_variable_declaration = true:suggestion
152+
csharp_prefer_simple_default_expression = true:suggestion
153+
csharp_style_pattern_local_over_anonymous_function = true:suggestion
154+
csharp_style_inlined_variable_declaration = true:suggestion
155+
156+
###############################
157+
# C# Formatting Rules #
158+
###############################
159+
160+
# Newline settings
161+
csharp_new_line_before_open_brace = methods,types
162+
csharp_new_line_before_else = false
163+
csharp_new_line_before_catch = false
164+
csharp_new_line_before_finally = false
165+
csharp_new_line_before_members_in_object_initializers = true
166+
csharp_new_line_before_members_in_anonymous_types = true
167+
168+
# Indentation preferences
169+
csharp_indent_switch_labels = false
170+
csharp_indent_case_contents = true
171+
csharp_indent_switch_labels = true
172+
173+
# Space preferences
174+
csharp_space_after_cast = true
175+
csharp_space_after_keywords_in_control_flow_statements = true
176+
csharp_space_between_method_call_parameter_list_parentheses = false
177+
csharp_space_between_method_declaration_parameter_list_parentheses = false
178+
csharp_space_between_parentheses = false
179+
csharp_space_before_colon_in_inheritance_clause = true
180+
csharp_space_after_colon_in_inheritance_clause = true
181+
csharp_space_around_binary_operators = before_and_after
182+
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
183+
csharp_space_between_method_call_name_and_opening_parenthesis = true
184+
csharp_space_between_method_call_empty_parameter_list_parentheses = false
185+
csharp_space_between_method_declaration_name_and_open_parenthesis = true
186+
csharp_space_after_keywords_in_control_flow_statements = true
187+
csharp_space_before_open_square_brackets = true
188+
189+
# Wrapping preferences
190+
csharp_preserve_single_line_statements = true
191+
csharp_preserve_single_line_blocks = true
192+
193+
##################################
194+
# Visual Basic Code Style Rules #
195+
##################################
196+
197+
[*.vb]
198+
# Modifier preferences
199+
visual_basic_preferred_modifier_order = Partial,Default,Private,Protected,Public,Friend,NotOverridable,Overridable,MustOverride,Overloads,Overrides,MustInherit,NotInheritable,Static,Shared,Shadows,ReadOnly,WriteOnly,Dim,Const,WithEvents,Widening,Narrowing,Custom,Async:suggestion

.vscode/extensions.json

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"recommendations": [
3+
"ms-vscode.csharp",
4+
"ms-vscode.mono-debug",
5+
"wghats.vscode-nxunit-test-adapter",
6+
"visualstudioexptteam.vscodeintellicode",
7+
]
8+
}

.vscode/launch.json

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": "Launch",
9+
"type": "mono",
10+
"request": "launch",
11+
"program": "${workspaceRoot}/packages/NUnit.ConsoleRunner.3.9.0/tools/nunit3-console.exe ${workspaceRoot}/bin/TestDebug/generator-Tests.dll",
12+
"cwd": "${workspaceRoot}bin/TestDebug/"
13+
},
14+
{
15+
"name": "Attach",
16+
"type": "mono",
17+
"request": "attach",
18+
"address": "localhost",
19+
"port": 55555
20+
}
21+
]
22+
}

.vscode/settings.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"nxunitExplorer.nunit": "packages/NUnit.ConsoleRunner.3.9.0/tools/nunit3-console.exe",
3+
"nxunitExplorer.modules": [
4+
"bin/TestDebug/Xamarin.Android.Tools.AndroidSdk-Tests.dll"
5+
]
6+
}

.vscode/tasks.json

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
// See https://go.microsoft.com/fwlink/?LinkId=733558
3+
// for the documentation about the tasks.json format
4+
"version": "2.0.0",
5+
"tasks": [
6+
{
7+
"label": "Build Xamarin.Android.Tools",
8+
"type": "shell",
9+
"command": "msbuild Xamarin.Android.Tools.sln /restore",
10+
"group": {
11+
"kind": "build",
12+
"isDefault": true
13+
},
14+
"problemMatcher": [
15+
"$msCompile"
16+
]
17+
},
18+
{
19+
"label": "Clean Xamarin.Android.Tools",
20+
"type": "shell",
21+
"command": "msbuild Xamarin.Android.Tools.sln /restore /t:Clean",
22+
"group": {
23+
"kind": "build",
24+
"isDefault": true
25+
},
26+
"problemMatcher": [
27+
"$msCompile"
28+
]
29+
},
30+
{
31+
"label": "Run Unit Tests",
32+
"type": "shell",
33+
"command": "make run-all-tests",
34+
"group": {
35+
"kind": "test",
36+
"isDefault": true
37+
},
38+
"problemMatcher": [
39+
"$msCompile"
40+
]
41+
}
42+
]
43+
}

Directory.Build.props

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<!-- Note: MUST be imported *after* $(Configuration) is set! -->
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
</PropertyGroup>
7+
<PropertyGroup>
8+
<BaseIntermediateOutputPath Condition=" '$(BaseIntermediateOutputPath)' == '' ">obj\</BaseIntermediateOutputPath>
9+
</PropertyGroup>
10+
<PropertyGroup Condition=" '$(TargetFramework)' != '' And $(TargetFramework.StartsWith ('netcoreapp')) ">
11+
<XATBuildingForNetCoreApp>True</XATBuildingForNetCoreApp>
12+
</PropertyGroup>
13+
<PropertyGroup Condition=" '$(XATBuildingForNetCoreApp)' == 'True' ">
14+
<IntermediateOutputPath>$(BaseIntermediateOutputPath)\$(Configuration)-$(TargetFramework.ToLowerInvariant())</IntermediateOutputPath>
15+
<BuildToolOutputFullPath>$(MSBuildThisFileDirectory)bin\Build$(Configuration)\$(TargetFramework.ToLowerInvariant())\</BuildToolOutputFullPath>
16+
<ToolOutputFullPath>$(MSBuildThisFileDirectory)bin\$(Configuration)\$(TargetFramework.ToLowerInvariant())\</ToolOutputFullPath>
17+
<TestOutputFullPath>$(MSBuildThisFileDirectory)bin\Test$(Configuration)-$(TargetFramework.ToLowerInvariant())\</TestOutputFullPath>
18+
</PropertyGroup>
19+
<PropertyGroup Condition=" '$(XATBuildingForNetCoreApp)' != 'True' ">
20+
<IntermediateOutputPath>$(BaseIntermediateOutputPath)\$(Configuration)</IntermediateOutputPath>
21+
<BuildToolOutputFullPath>$(MSBuildThisFileDirectory)bin\Build$(Configuration)\</BuildToolOutputFullPath>
22+
<ToolOutputFullPath>$(MSBuildThisFileDirectory)bin\$(Configuration)\</ToolOutputFullPath>
23+
<TestOutputFullPath>$(MSBuildThisFileDirectory)bin\Test$(Configuration)\</TestOutputFullPath>
24+
</PropertyGroup>
25+
</Project>

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ V ?= 0
77
include build-tools/scripts/msbuild.mk
88

99
all:
10-
$(MSBUILD) $(MSBUILD_FLAGS) Xamarin.Android.Tools.sln
10+
$(MSBUILD) /restore $(MSBUILD_FLAGS) Xamarin.Android.Tools.sln
1111

1212
clean:
1313
-$(MSBUILD) $(MSBUILD_FLAGS) /t:Clean Xamarin.Android.Tools.sln

NuGet.config

+4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
Our testing infrastructure depends on a known location for:
4+
- nunit3-console.exe
5+
-->
26
<configuration>
37
<packageSources>
48
<clear />

Xamarin.Android.Tools.code-workspace

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"folders": [
3+
{
4+
"path": "."
5+
}
6+
],
7+
"settings": {
8+
}
9+
}

0 commit comments

Comments
 (0)