Skip to content

Commit 1d2c363

Browse files
authored
Merge pull request #5 from bdovaz/main
- The program is parameterizable so that it is compatible with Unity packages. - Project converted to cli distributed in NuGet as a cross platform dotnet tool. - Added a test command that, when passed an xrefmap file, allows you to test the links in the href field. - Added tests. - Patched more cases with string replace so that it generates the documentation correctly. - Generate the xrefmaps of the Unity Editor with the GitHub Actions workflow for supported Unity builds only, using the Unity's releases API
2 parents 1316008 + 8327054 commit 1d2c363

40 files changed

+2429
-547
lines changed

.config/dotnet-tools.json

Lines changed: 0 additions & 12 deletions
This file was deleted.

.editorconfig

Lines changed: 201 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,201 @@
1+
# editorconfig.org
2+
3+
# top-most EditorConfig file
4+
root = true
5+
6+
# Default settings:
7+
# A newline ending every file
8+
# Use 4 spaces as indentation
9+
[*]
10+
insert_final_newline = true
11+
indent_style = space
12+
indent_size = 4
13+
trim_trailing_whitespace = true
14+
15+
# Specify UTF-8 without byte-order mark
16+
[*.{csproj,locproj,nativeproj,proj,resx,slnx,vbproj}]
17+
charset = utf-8
18+
19+
# Generated code
20+
[*{_AssemblyInfo.cs,.notsupported.cs,AsmOffsets.cs}]
21+
generated_code = true
22+
23+
# C# files
24+
[*.cs]
25+
# New line preferences
26+
csharp_new_line_before_open_brace = all
27+
csharp_new_line_before_else = true
28+
csharp_new_line_before_catch = true
29+
csharp_new_line_before_finally = true
30+
csharp_new_line_before_members_in_object_initializers = true
31+
csharp_new_line_before_members_in_anonymous_types = true
32+
csharp_new_line_between_query_expression_clauses = true
33+
34+
# Indentation preferences
35+
csharp_indent_block_contents = true
36+
csharp_indent_braces = false
37+
csharp_indent_case_contents = true
38+
csharp_indent_case_contents_when_block = false
39+
csharp_indent_switch_labels = true
40+
csharp_indent_labels = one_less_than_current
41+
42+
# Modifier preferences
43+
csharp_preferred_modifier_order = public,private,protected,internal,file,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,required,volatile,async:suggestion
44+
45+
# avoid this. unless absolutely necessary
46+
dotnet_style_qualification_for_field = false:suggestion
47+
dotnet_style_qualification_for_property = false:suggestion
48+
dotnet_style_qualification_for_method = false:suggestion
49+
dotnet_style_qualification_for_event = false:suggestion
50+
51+
# Types: use keywords instead of BCL types, and permit var only when the type is clear
52+
csharp_style_var_for_built_in_types = false:suggestion
53+
csharp_style_var_when_type_is_apparent = false:none
54+
csharp_style_var_elsewhere = false:suggestion
55+
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
56+
dotnet_style_predefined_type_for_member_access = true:suggestion
57+
58+
# name all constant fields using PascalCase
59+
dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = suggestion
60+
dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols = constant_fields
61+
dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style
62+
dotnet_naming_symbols.constant_fields.applicable_kinds = field
63+
dotnet_naming_symbols.constant_fields.required_modifiers = const
64+
dotnet_naming_style.pascal_case_style.capitalization = pascal_case
65+
66+
# static fields should have s_ prefix
67+
dotnet_naming_rule.static_fields_should_have_prefix.severity = suggestion
68+
dotnet_naming_rule.static_fields_should_have_prefix.symbols = static_fields
69+
dotnet_naming_rule.static_fields_should_have_prefix.style = static_prefix_style
70+
dotnet_naming_symbols.static_fields.applicable_kinds = field
71+
dotnet_naming_symbols.static_fields.required_modifiers = static
72+
dotnet_naming_symbols.static_fields.applicable_accessibilities = private, internal, private_protected
73+
dotnet_naming_style.static_prefix_style.required_prefix = s_
74+
dotnet_naming_style.static_prefix_style.capitalization = camel_case
75+
76+
# internal and private fields should be _camelCase
77+
dotnet_naming_rule.camel_case_for_private_internal_fields.severity = suggestion
78+
dotnet_naming_rule.camel_case_for_private_internal_fields.symbols = private_internal_fields
79+
dotnet_naming_rule.camel_case_for_private_internal_fields.style = camel_case_underscore_style
80+
dotnet_naming_symbols.private_internal_fields.applicable_kinds = field
81+
dotnet_naming_symbols.private_internal_fields.applicable_accessibilities = private, internal
82+
dotnet_naming_style.camel_case_underscore_style.required_prefix = _
83+
dotnet_naming_style.camel_case_underscore_style.capitalization = camel_case
84+
85+
# Code style defaults
86+
csharp_using_directive_placement = outside_namespace:suggestion
87+
dotnet_sort_system_directives_first = true
88+
csharp_prefer_braces = true:silent
89+
csharp_preserve_single_line_blocks = true:none
90+
csharp_preserve_single_line_statements = false:none
91+
csharp_prefer_static_local_function = true:suggestion
92+
csharp_prefer_simple_using_statement = false:none
93+
csharp_style_prefer_switch_expression = true:suggestion
94+
dotnet_style_readonly_field = true:suggestion
95+
96+
# Expression-level preferences
97+
dotnet_style_object_initializer = true:suggestion
98+
dotnet_style_collection_initializer = true:suggestion
99+
dotnet_style_prefer_collection_expression = when_types_exactly_match
100+
dotnet_style_explicit_tuple_names = true:suggestion
101+
dotnet_style_coalesce_expression = true:suggestion
102+
dotnet_style_null_propagation = true
103+
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
104+
dotnet_style_prefer_inferred_tuple_names = true:suggestion
105+
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
106+
dotnet_style_prefer_auto_properties = true:suggestion
107+
dotnet_style_prefer_conditional_expression_over_assignment = true:silent
108+
dotnet_style_prefer_conditional_expression_over_return = true:silent
109+
csharp_prefer_simple_default_expression = true:suggestion
110+
111+
# Expression-bodied members
112+
csharp_style_expression_bodied_methods = true:silent
113+
csharp_style_expression_bodied_constructors = true:silent
114+
csharp_style_expression_bodied_operators = true:silent
115+
csharp_style_expression_bodied_properties = true:silent
116+
csharp_style_expression_bodied_indexers = true:silent
117+
csharp_style_expression_bodied_accessors = true:silent
118+
csharp_style_expression_bodied_lambdas = true:silent
119+
csharp_style_expression_bodied_local_functions = true:silent
120+
121+
# Pattern matching
122+
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
123+
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
124+
csharp_style_inlined_variable_declaration = true:suggestion
125+
126+
# Null checking preferences
127+
csharp_style_throw_expression = true:suggestion
128+
csharp_style_conditional_delegate_call = true:suggestion
129+
130+
# Other features
131+
csharp_style_prefer_index_operator = false:none
132+
csharp_style_prefer_range_operator = false:none
133+
csharp_style_pattern_local_over_anonymous_function = false:none
134+
135+
# Space preferences
136+
csharp_space_after_cast = false
137+
csharp_space_after_colon_in_inheritance_clause = true
138+
csharp_space_after_comma = true
139+
csharp_space_after_dot = false
140+
csharp_space_after_keywords_in_control_flow_statements = true
141+
csharp_space_after_semicolon_in_for_statement = true
142+
csharp_space_around_binary_operators = before_and_after
143+
csharp_space_around_declaration_statements = do_not_ignore
144+
csharp_space_before_colon_in_inheritance_clause = true
145+
csharp_space_before_comma = false
146+
csharp_space_before_dot = false
147+
csharp_space_before_open_square_brackets = false
148+
csharp_space_before_semicolon_in_for_statement = false
149+
csharp_space_between_empty_square_brackets = false
150+
csharp_space_between_method_call_empty_parameter_list_parentheses = false
151+
csharp_space_between_method_call_name_and_opening_parenthesis = false
152+
csharp_space_between_method_call_parameter_list_parentheses = false
153+
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
154+
csharp_space_between_method_declaration_name_and_open_parenthesis = false
155+
csharp_space_between_method_declaration_parameter_list_parentheses = false
156+
csharp_space_between_parentheses = false
157+
csharp_space_between_square_brackets = false
158+
159+
# License header
160+
file_header_template =
161+
162+
[src/libraries/System.Net.Http/src/System/Net/Http/{SocketsHttpHandler/Http3RequestStream.cs,BrowserHttpHandler/BrowserHttpHandler.cs}]
163+
# disable CA2025, the analyzer throws a NullReferenceException when processing this file: https://github.com/dotnet/roslyn-analyzers/issues/7652
164+
dotnet_diagnostic.CA2025.severity = none
165+
166+
# C++ Files
167+
[*.{cpp,h,in}]
168+
curly_bracket_next_line = true
169+
indent_brace_style = Allman
170+
171+
# Xml project files
172+
[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,nativeproj,locproj}]
173+
indent_size = 2
174+
175+
# Xml build files
176+
[*.builds]
177+
indent_size = 2
178+
179+
# Xml files
180+
[*.{resx,ruleset,slnx,stylecop,xml}]
181+
indent_size = 2
182+
183+
# Xml resource files
184+
[*.resx]
185+
# match Visual Studio behavior
186+
insert_final_newline = false
187+
trim_trailing_whitespace = false
188+
189+
# Xml config files
190+
[*.{props,targets,config,nuspec}]
191+
indent_size = 2
192+
193+
# Data serialization
194+
[*.{json,yaml,yml}]
195+
indent_size = 2
196+
197+
# Shell scripts
198+
[*.sh]
199+
end_of_line = lf
200+
[*.{cmd,bat}]
201+
end_of_line = crlf

.github/workflows/ci.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
name: ci
3+
4+
on:
5+
push:
6+
branches:
7+
- main
8+
pull_request:
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v5
17+
18+
- name: Install DocFX
19+
run: dotnet tool install --global docfx
20+
21+
- name: Build & test (Release)
22+
run: dotnet test -c Release

docfx.json renamed to .github/workflows/resources/docfx.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,16 @@
99
"filter": "filterConfig.yml",
1010
"dest": "UnityCsReference/_api",
1111
"disableGitFeatures": true,
12-
"noRestore": true,
12+
"allowCompilationErrors": true,
1313
"properties": {
14-
"Configuration": "Debug"
14+
"AllowUnsafeBlocks": "true"
1515
}
1616
}
1717
],
18-
"build":
19-
{
20-
"xrefService": [ "https://xref.docs.microsoft.com/query?uid={uid}" ],
18+
"build": {
19+
"xref": [
20+
"https://learn.microsoft.com/en-us/dotnet/.xrefmap.json"
21+
],
2122
"content": [
2223
{
2324
"src": "UnityCsReference/_api",
@@ -27,4 +28,4 @@
2728
],
2829
"dest": "UnityCsReference/_site"
2930
}
30-
}
31+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
### YamlMime:ManagedReference
2+
---
3+
apiRules:
4+
- exclude:
5+
uidRegex: ^AOT
6+
- exclude:
7+
uidRegex: ^JetBrains
8+
- exclude:
9+
uidRegex: ^TreeEditor
10+
- exclude:
11+
uidRegex: ^Unity\.CodeEditor
12+
- exclude:
13+
uidRegex: ^UnityEditorInternal
14+
- exclude:
15+
uidRegex: ^UnityEditor\.InspectorMode
16+
- exclude:
17+
uidRegex: ^UnityEngineInternal
18+
- exclude:
19+
uidRegex: ^UnityEngine.Internal
20+
- exclude:
21+
uidRegex: Finalize$
22+
- exclude:
23+
hasAttribute:
24+
uid: UnityEngine.Internal.ExcludeFromDocsAttribute

.github/workflows/tool.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
---
2+
name: tool
3+
4+
on:
5+
push:
6+
branches:
7+
- main
8+
tags:
9+
- '*'
10+
pull_request:
11+
12+
jobs:
13+
build:
14+
runs-on: ubuntu-latest
15+
16+
permissions:
17+
id-token: write
18+
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v5
22+
23+
- name: Should Deploy?
24+
if: ${{ success() && github.event_name == 'push' }}
25+
shell: pwsh
26+
run: |
27+
if ("${{github.ref}}" -match "^refs/tags/([0-9]+\.[0-9]+\.[0-9]+)")
28+
{
29+
$version = $Matches[1]
30+
31+
echo "UNITY_XREF_MAPS_DEPLOY=1" >> $env:GITHUB_ENV
32+
echo "UNITY_XREF_MAPS_VERSION=$version" >> $env:GITHUB_ENV
33+
}
34+
35+
- name: Pack
36+
if: ${{ success() && env.UNITY_XREF_MAPS_DEPLOY != 1 }}
37+
run: dotnet pack UnityXrefMaps/UnityXrefMaps.csproj -c Release -o ${{ runner.temp }}
38+
39+
- name: Pack (Release)
40+
if: ${{ success() && env.UNITY_XREF_MAPS_DEPLOY == 1 }}
41+
run: dotnet pack UnityXrefMaps/UnityXrefMaps.csproj -c Release -p:PackageVersion=$UNITY_XREF_MAPS_VERSION -o ${{ runner.temp }}
42+
43+
- name: NuGet login
44+
if: ${{ success() && env.UNITY_XREF_MAPS_DEPLOY == 1 }}
45+
uses: NuGet/login@v1
46+
id: login
47+
with:
48+
user: ${{ secrets.NUGET_USER }}
49+
50+
- name: Publish (Release)
51+
if: ${{ success() && env.UNITY_XREF_MAPS_DEPLOY == 1 }}
52+
run: |
53+
dotnet nuget push ${{ runner.temp }}/UnityXrefMaps.${{ env.UNITY_XREF_MAPS_VERSION }}.nupkg \
54+
--source https://api.nuget.org/v3/index.json \
55+
--api-key ${{ steps.login.outputs.NUGET_API_KEY }}

0 commit comments

Comments
 (0)