Skip to content

Commit d3ca6e4

Browse files
authored
Added multi targetting for source generation (#348)
* This includes `Ubiquity.NET.Extensions` and `Ubiquity.NET.SrcGeneration` * Added SrcGeneration project to the docs - Apparently that was missed in previos commits somehow - This includes updates on how some things like lists are handled. - Guidance is now provided for help * Updated all `toc.yml` files to indicate correct use. - They were mostly copy/pasted and included the incorrect folder use as a result. * Exclude test projects from code coverage - Most this is a simple `[assembly: ExcludeFromCodeCoverage]` - However that attribute doesn't support assembly level use for down level and therefore ***MUST*** be applied to each test class/helper.etc... for multi-targetting test libraries. * Moved Fluent validation into a distinct namespace to support disambiguation of extensions when targetting down level runtimes * Added testing of Extensions and SrcGeneration for multi-targetting * Updated docfx tool version to 2.78.4 as that has support for C#14 language additions. - This allows generation of docs for code using the new `extension` keyword. Eliminationg one of the major blockers for not using that.
1 parent c5b6cab commit d3ca6e4

77 files changed

Lines changed: 2875 additions & 326 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.

Build-Docs.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Param(
2727
[switch]$ShowDocs
2828
)
2929

30-
$docFXToolVersion = '2.78.3'
30+
$docFXToolVersion = '2.78.4'
3131

3232
$InformationPreference = 'Continue'
3333
$ErrorInformationPreference = 'Stop'

Build-Source.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ try
3131
$buildInfo = Initialize-BuildEnvironment -FullInit:$FullInit
3232

3333
# build the Managed code support
34-
Write-Information "dotnet build 'src\Ubiquity.NET.Llvm.slnx' -c $Configuration"
34+
Write-Information "dotnet build --tl:off 'src\Ubiquity.NET.Llvm.slnx' -c $Configuration"
3535
Invoke-External dotnet build --tl:off 'src\Ubiquity.NET.Llvm.slnx' '-c' $Configuration
3636
}
3737
catch

Directory.Build.targets

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
will ensure the folder exists during restore so that it won't fail.
1111
-->
1212
<Target Name="EnsureBuildOutputPaths" Condition="!Exists($(PackageOutputPath))">
13+
<Message Importance="high" Text="PackageOutputPath: $(PackageOutputPath)"/>
1314
<MakeDir Directories="$(PackageOutputPath)"/>
1415
</Target>
1516

@@ -26,6 +27,7 @@
2627
<Message Importance="normal" Text=" Platform: $(Platform)"/>
2728
<Message Importance="normal" Text=" Configuration: $(Configuration)"/>
2829
<Message Importance="normal" Text=" NETCoreSdkVersion: $(NETCoreSdkVersion)"/>
30+
<Message Importance="normal" Text=" TargetFramework: $(TargetFramework)"/>
2931
</Target>
3032

3133
<Target Name="VerifyProjectSettings" Condition="'$(MSBuildProjectExtension)'=='.csproj'">

Directory.Packages.props

Lines changed: 46 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,57 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3-
<!--
3+
<!--
44
Global references are included in ALL projects in this repository
5-
-->
6-
<ItemGroup>
7-
<GlobalPackageReference Include="Ubiquity.NET.Versioning.Build.Tasks" Version="5.0.7-alpha.0.1" />
8-
<GlobalPackageReference Include="IDisposableAnalyzers" Version="4.0.8" Condition="'$(NoCommonAnalyzers)' !=' true'" />
9-
<GlobalPackageReference Include="MustUseRetVal" Version="0.0.2" Condition="'$(NoCommonAnalyzers)' !=' true'" />
10-
<!--
5+
-->
6+
<ItemGroup>
7+
<GlobalPackageReference Include="Ubiquity.NET.Versioning.Build.Tasks" Version="5.0.7" />
8+
<GlobalPackageReference Include="IDisposableAnalyzers" Version="4.0.8" Condition="'$(NoCommonAnalyzers)' !=' true'" />
9+
<GlobalPackageReference Include="MustUseRetVal" Version="0.0.2" Condition="'$(NoCommonAnalyzers)' !=' true'" />
10+
<!--
1111
NOTE: This analyzer is sadly, perpetually in "pre-release mode". There have been many issues/discussion on the point
1212
and it has all fallen on deaf ears. So policies regarding "NO-Prerelease" components need to be overruled on this one
1313
-->
14-
<GlobalPackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.556" Condition="'$(UseStyleCop)' != 'false'" />
15-
</ItemGroup>
16-
<!--
14+
<GlobalPackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.556" Condition="'$(UseStyleCop)' != 'false'" />
15+
</ItemGroup>
16+
17+
<!--
1718
Package versions made consistent across all packages referenced in this repository
18-
-->
19-
<ItemGroup>
20-
<!-- Roslyn Analyzers ***MUST*** target older framework -->
21-
<PackageVersion Include="AnsiCodes" Version="0.2.1" />
22-
<PackageVersion Include="Microsoft.CodeAnalysis" Version="4.14.0" />
23-
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="4.14.0" />
24-
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.14.0" />
25-
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Features" Version="4.14.0" />
26-
<PackageVersion Include="Microsoft.CodeAnalysis.VisualBasic.Features" Version="4.14.0" />
27-
<PackageVersion Include="Basic.Reference.Assemblies.Net80" Version="1.8.3" />
28-
<PackageVersion Include="System.Buffers" Version="4.6.1" />
29-
<PackageVersion Include="System.Collections.Immutable" Version="9.0.8" />
30-
<PackageVersion Include="System.CommandLine" Version="2.0.0-rc.2.25502.107" />
19+
-->
20+
<ItemGroup>
21+
<!-- Roslyn Analyzers ***MUST*** target older framework -->
22+
<PackageVersion Include="AnsiCodes" Version="0.2.1" />
23+
<PackageVersion Include="Microsoft.CodeAnalysis" Version="4.14.0" />
24+
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="4.14.0" />
25+
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.14.0" />
26+
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Features" Version="4.14.0" />
27+
<PackageVersion Include="Microsoft.CodeAnalysis.VisualBasic.Features" Version="4.14.0" />
28+
<PackageVersion Include="Basic.Reference.Assemblies.Net80" Version="1.8.3" />
29+
<PackageVersion Include="PolySharp" Version="1.15.0" />
30+
<PackageVersion Include="System.Buffers" Version="4.6.1" />
31+
<PackageVersion Include="System.Collections.Immutable" Version="9.0.10" />
32+
<PackageVersion Include="System.CommandLine" Version="2.0.0-rc.2.25502.107" />
3133

32-
<!-- Security vulnerability overrides -->
33-
<!-- Workaround(2): https://github.com/dotnet/roslyn-sdk/issues/1191 -->
34-
<PackageVersion Include="System.Formats.Asn1" Version="9.0.10" />
34+
<!-- Security vulnerability overrides -->
35+
<!-- Workaround(2): https://github.com/dotnet/roslyn-sdk/issues/1191 -->
36+
<PackageVersion Include="System.Formats.Asn1" Version="9.0.10" />
3537

36-
<!-- Common packages for solution -->
37-
<PackageVersion Include="System.Linq.Async" Version="6.0.3" />
38-
<PackageVersion Include="Ubiquity.NET.LibLLVM" Version="20.1.8" />
39-
<PackageVersion Include="Ubiquity.NET.Versioning" Version="6.0.2-beta" />
40-
<PackageVersion Include="Antlr4BuildTasks" Version="12.11.0" />
41-
<PackageVersion Include="Antlr4.Runtime.Standard" Version="4.13.1" />
42-
<PackageVersion Include="OpenSoftware.DgmlBuilder" Version="2.1.0" />
43-
<PackageVersion Include="CppSharp" Version="1.1.5.3168" />
44-
<PackageVersion Include="System.CodeDom" Version="9.0.7" />
38+
<!-- Common packages for solution -->
39+
<PackageVersion Include="System.Linq.Async" Version="6.0.3" />
40+
<PackageVersion Include="Ubiquity.NET.LibLLVM" Version="20.1.8" />
41+
<PackageVersion Include="Ubiquity.NET.Versioning" Version="6.0.2-beta" />
42+
<PackageVersion Include="Antlr4BuildTasks" Version="12.11.0" />
43+
<PackageVersion Include="Antlr4.Runtime.Standard" Version="4.13.1" />
44+
<PackageVersion Include="OpenSoftware.DgmlBuilder" Version="2.1.0" />
45+
<PackageVersion Include="CppSharp" Version="1.1.5.3168" />
46+
<PackageVersion Include="System.CodeDom" Version="9.0.7" />
4547

46-
<!-- Tests all use the same framework versions -->
47-
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.0.0" />
48-
<PackageVersion Include="MSTest.TestAdapter" Version="4.0.1" />
49-
<PackageVersion Include="MSTest.TestFramework" Version="4.0.1" />
50-
<PackageVersion Include="Tmds.ExecFunction" Version="0.8.0" />
51-
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Analyzer.Testing" Version="1.1.2" />
52-
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.CodeFix.Testing" Version="1.1.2" />
53-
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.CodeRefactoring.Testing" Version="1.1.2" />
54-
</ItemGroup>
48+
<!-- Tests all use the same framework versions -->
49+
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.0.0" />
50+
<PackageVersion Include="MSTest.TestAdapter" Version="4.0.1" />
51+
<PackageVersion Include="MSTest.TestFramework" Version="4.0.1" />
52+
<PackageVersion Include="Tmds.ExecFunction" Version="0.8.0" />
53+
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Analyzer.Testing" Version="1.1.2" />
54+
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.CodeFix.Testing" Version="1.1.2" />
55+
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.CodeRefactoring.Testing" Version="1.1.2" />
56+
</ItemGroup>
5557
</Project>

OneFlow/ReadMe.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ This repository follows the [OneFlow](https://www.endoflineblog.com/oneflow-a-gi
44
model and work-flow. With one active long term branch 'develop'. The master branch is
55
present and long term but is not active, it only points to the latest official release
66
(including preview releases) of the project. This is a convenience to allow getting the
7-
latests released source quickly. Generally the scripts used here are only for release
8-
managers and are not required (or even an option) for most contributors.
7+
latest released source quickly. Generally speaking, the scripts used here are only for
8+
release managers and are not required (or even an option) for most contributors.

Show-Docs.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Param(
1818
[string]$DocsPathToHost
1919
)
2020

21-
$docFXToolVersion = '2.78.3'
21+
$docFXToolVersion = '2.78.4'
2222

2323
$InformationPreference = 'Continue'
2424
$ErrorInformationPreference = 'Stop'

docfx/CommandLine/toc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# TOC (Left nav) for the 'extensions' folder
1+
# TOC (Left nav) for the 'CommandLine' folder
22
- name: Overview
33
href: index.md
44
- name: Namespaces

docfx/ReadMe.md

Lines changed: 81 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,19 @@ DocFX is used to generate the documentation for this library. There is confusion
1010
***DOES NOT*** mean that the default+modern template is unusable for hosted static site
1111
scenarios like 'gh-pages' in GitHub. It only means that the TOC support will
1212
***require*** a hosted site to provide the contents needed by the generated TOC client side
13-
scripting. That's it. Don't fear the built-in templates (Despite the lack of decent docs
14-
explaining the details [Yeah, this project previously fell into those gaps and even
13+
scripting. That's it. Don't fear the built-in templates - despite the lack of decent docs
14+
explaining the details! [Yeah, this project previously fell into those gaps and even
1515
constructed a complete custom template to deal with it... Sigh, what a waste of time...
16-
:facepalm: ])
16+
:facepalm: ]
1717

1818
## Changes Over Time
1919
DocFX has obsoleted the `docfxconsole` NuGet package that was used to run docfx for a
2020
project via MSBUILD. Instead it focused on a .NET tool to do it all via the command line.
21-
Ultimately the docfx.json serves as the "project" file for the different site builds.
22-
The PowerShell script `Build-Docs.ps1` was updated to use the new tool directly. Using that
23-
script should have little or no impact on the overall flow. There is a "no-targets" project
24-
in the solution to enable easier access to the input files but does not itself, generate any
25-
docs - it's just a placeholder.
21+
Ultimately the docfx.json serves as the corellary to a "project" file for the different site
22+
builds. The PowerShell script `Build-Docs.ps1` was updated to use the new tool directly.
23+
Using that script should have little or no impact on the overall flow. There is a
24+
"no-targets" project in the solution to enable easier access to the input files but does not
25+
itself, generate any docs - it's just a placeholder.
2626

2727
## Files used by the docs generation
2828
There are a lot of files used to generate the docs and the concept of a Table of Contents
@@ -77,3 +77,76 @@ Since this is generated it is listed in the [.gitignore](#gitignore) file.
7777
#### Library Content
7878
These folders (named after the `*` portion of the [api-*](#api-*) folder names contains
7979
manually written additional files, articles, samples etc... related to a given library.
80+
81+
## Guid to wrting XML DOC comments
82+
When dealing with doc comments the XML can get in the way of general readability of the
83+
source code. There is an inherent tension beween how a particular editor renders the docs
84+
for a symbol/method (VS calls this "Quick Info") and how it is rendered in the final
85+
documentation by docfx. This guides general use to simplify things as much as possible.
86+
87+
### Lists
88+
The largest intrusion of the XML into the source is that of lists. The XML doc comments
89+
official support is to use the `<list>` tag. However, that is VERY intrusive and doesn't
90+
easily support sub-lists. Consider:
91+
92+
``` C#
93+
/// Additional steps might include:
94+
/// <para>
95+
/// <list type="number">
96+
/// <item>App specific Validation/semantic analysis</item>
97+
/// <item>Binding of results to an app specific type</item>
98+
/// <item>
99+
/// Act on the results as proper for the application
100+
/// <list type="number">
101+
/// <item>This might include actions parsed but generally isolating the various stages is an easier to understand/maintain model</item>
102+
/// <item>Usually this is just app specific code that uses the bound results to adapt behavior</item>
103+
/// </list>
104+
/// </item>
105+
/// </list>
106+
/// </para>
107+
```
108+
109+
versus:
110+
``` C#
111+
/// Additional steps might include:<br/>
112+
///
113+
/// 1) App specific Validation/semantic analysis<br/>
114+
/// 2) Binding of results to an app specific type<br/>
115+
/// 3) Act on the results as proper for the application<br/>
116+
/// a. This might include actions parsed but generally isolating the various stages is an easier to understand/maintain model<br/>
117+
/// b. Usually this is just app specific code that uses the bound results to adapt behavior<br/>
118+
///
119+
```
120+
121+
Which one would ***YOU*** rather encounter in code? Which one is easier to understand when
122+
reading the source? This repo chooses the latter. (If you favor the former, perhaps you
123+
should reconsider... :grinning:)
124+
125+
#### How to handle lists
126+
There is little that can be done to alter the rendering of any editor support, at most an
127+
editor might allow specification of a CSS file, but that is the lowest priority of doc
128+
comments. Readability by maintainers of the docs AND the rendering for final docs used by
129+
consumers of of VASTLY higher importance. Still, the editor rendering ***is*** of value to
130+
maintainers so should not be forgotten as it can make a "right mess of things" even if they
131+
render properly in final docs.
132+
133+
##### Guidance
134+
1) ***DO NOT*** use `<para>` tags to include any lists
135+
a) Doing so will break the docfx rendering that allows for markdown lists
136+
2) Use `</br>' tags to indicate a line break. This is used by the editor rendering to mark
137+
the end of a line and start a new one. (Stops auto reflow)
138+
3) Accept that the in edotr rendering might "trim" the lines it shows, eliminating any
139+
indentation.
140+
a) Sadly, there is no avoiding this. Addition of any sort of "markup" to control that
141+
will interfere with the readability AND the final docs rendering.
142+
4) Always use a different numbering style for sub lists/items
143+
b) This will at least show in the in-editor rendering as distinct sub items so if
144+
everything is trimmed it is at least a distinct pattern that is readable.
145+
5) ***DO NOT*** put lists in any place other than inside a `remarks` region
146+
a) Usually, the remarks comments are not even rendered as the most useful part is the
147+
API signaure and parameter info. Different editors may allow control of that.
148+
i) In VS [2019|2022] for C# it is controlled by
149+
`Text Editor > C# > Advanced > Editor Help: "Show remarks in Quick Info."`
150+
ii) Turning this off can greatly reduce the noise AND reduce the problems of
151+
different rende
152+

docfx/SrcGeneration/api/index.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Ubiquity.NET.SrcGeneration
2+
This library contains support functionality to aid in building a source generator.
3+
This library is multi-targetting to allow consumption from a Roslyn source generator
4+
or VSIX project. Other uses should leverage the modern runtimes but those cases
5+
***MUST*** target only `.NET Standard 2.0`
6+

docfx/SrcGeneration/index.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Ubiquity.NET.SrcGeneration
2+
This library contains support functionality to aid in building a source generator.
3+
This library is multi-targetting to allow consumption from a Roslyn source generator
4+
or VSIX project. Other uses should leverage the modern runtimes but those cases
5+
***MUST*** target only `.NET Standard 2.0`
6+

0 commit comments

Comments
 (0)