Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ indent_size = 2
tab_width = 2

[*.md]
# mark left margion for split screen preview of markdown files
# mark left margin for split screen preview of markdown files
# requires: https://marketplace.visualstudio.com/items?itemName=PaulHarrington.EditorGuidelinesPreview
guidelines = 92

Expand Down Expand Up @@ -133,31 +133,31 @@ dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case

dotnet_naming_symbols.interface.applicable_kinds = interface
dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.interface.required_modifiers =
dotnet_naming_symbols.interface.required_modifiers =

dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum
dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.types.required_modifiers =
dotnet_naming_symbols.types.required_modifiers =

dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method
dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.non_field_members.required_modifiers =
dotnet_naming_symbols.non_field_members.required_modifiers =

# Naming styles

dotnet_naming_style.begins_with_i.required_prefix = I
dotnet_naming_style.begins_with_i.required_suffix =
dotnet_naming_style.begins_with_i.word_separator =
dotnet_naming_style.begins_with_i.required_suffix =
dotnet_naming_style.begins_with_i.word_separator =
dotnet_naming_style.begins_with_i.capitalization = pascal_case

dotnet_naming_style.pascal_case.required_prefix =
dotnet_naming_style.pascal_case.required_suffix =
dotnet_naming_style.pascal_case.word_separator =
dotnet_naming_style.pascal_case.required_prefix =
dotnet_naming_style.pascal_case.required_suffix =
dotnet_naming_style.pascal_case.word_separator =
dotnet_naming_style.pascal_case.capitalization = pascal_case

dotnet_naming_style.pascal_case.required_prefix =
dotnet_naming_style.pascal_case.required_suffix =
dotnet_naming_style.pascal_case.word_separator =
dotnet_naming_style.pascal_case.required_prefix =
dotnet_naming_style.pascal_case.required_suffix =
dotnet_naming_style.pascal_case.word_separator =
dotnet_naming_style.pascal_case.capitalization = pascal_case
dotnet_style_coalesce_expression = true:warning
dotnet_style_null_propagation = true:warning
Expand Down
23 changes: 23 additions & 0 deletions IgnoredWords.dic
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ accessors
Addr
addref
alloca
amongst
anonymize
antlr
api
Expand Down Expand Up @@ -34,10 +35,13 @@ buildtransitive
builtinop
byref
byval
Cacheable
callee
canonicalization
castable
checkin
cibuild
cmake
Cmp
Comdat
Comdats
Expand Down Expand Up @@ -71,6 +75,7 @@ fallback
finalizer
finalizers
foo
formattable
fullsrc
func
getelementptr
Expand All @@ -83,21 +88,26 @@ Identifier
ifunc
Impl
initializer
initializers
inline
inlined
inlining
Installshield
Interop
ints
invocable
jit
len
Lexer
LibLLVM
Licensor
Llilum
llvm
llvmversion
lookups
LValue
malloc
marshalers
marshallers
marshalling
materializer
Expand All @@ -110,9 +120,12 @@ minimalistic
Mips
msbuild
msg
namespace
namespaces
nav
nint
noinline
nop
nounwind
nuint
nullability
Expand All @@ -125,7 +138,9 @@ outdent
pages
paren
perf
performant
pointee
Polyfill
polyfills
pragma
pragmas
Expand All @@ -143,6 +158,7 @@ runtimes
RValue
servable
shaders
Silverlight
sizeof
Sparc
src
Expand All @@ -152,9 +168,11 @@ struct
structs
Subrange
Sym
Tag
telliam
templated
templating
theming
tl
trx
typdef
Expand All @@ -165,8 +183,11 @@ typeof
uid
uint
unaryop
uncached
Uncomment
Undefine
undiscoverable
unencrypted
Unhandled
uniqued
uniqueing
Expand All @@ -175,6 +196,7 @@ unmarshal
unoptimized
unreferenced
Unshipped
untrusted
userdefinedop
Users
usings
Expand All @@ -185,6 +207,7 @@ variadic
vcxproj
versioned
versioning
wwwroot
Xchg
Xor
xref
Expand Down
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,20 @@
# Ubiquity.NET.Utils
Utility packages
Utility packages To support a variety of scenarios. This repository is mostly a [Grab Bag](https://www.wordnik.com/words/grab%20bag)
of multiple small libraries that didn't warrant a distinct repository.

| Library | Description |
|---------|-------------|
| [Ubiquity.NET.Antlr.Utils](https://ubiquitydotnet.github.io/Ubiquity.NET.Utils/antlr-utils/index.html) | This library contains extensions and helpers for using ANTLR with .NET |
| [Ubiquity.NET.CodeAnalysis.Utils](https://ubiquitydotnet.github.io/Ubiquity.NET.Utils/CodeAnalysis/index.html) | This library contains extensions and helpers for using Roslyn CodeAnalysis |
| [Ubiquity.NET.CommandLine](https://ubiquitydotnet.github.io/Ubiquity.NET.Utils/CommandLine/index.html) | This library contains extensions and helpers for command line parsing via `System.CommandLine` |
| [Ubiquity.NET.Extensions](https://ubiquitydotnet.github.io/Ubiquity.NET.Utils/extensions/index.html) | This library contains general extensions and helpers for many scenarios using .NET |
| [Ubiquity.NET.InteropHelpers](https://ubiquitydotnet.github.io/Ubiquity.NET.Utils/interop-helpers/index.html) | This library contains extensions and helpers for implementing interop support for native libraries |
| [Ubiquity.NET.Runtime.Utils](https://ubiquitydotnet.github.io/Ubiquity.NET.Utils/runtime-utils/index.html) | This library contains common support for DSL runtime and language implementers |
| [Ubiquity.NET.SourceGenerator.Test.Utils](https://ubiquitydotnet.github.io/Ubiquity.NET.Utils/src-gen-test-utils/index.html) | This library contains extensions and helpers for testing source generators |
| [Ubiquity.NET.SrcGeneration](https://ubiquitydotnet.github.io/Ubiquity.NET.Utils/SrcGeneration/index.html) | This library contains extensions and helpers for implementing source generators |

>[!IMPORTANT]
> When editing code in this repository make certain that any extensions or tooling that
> automatically removes trailing whitespace is disabled. It is fine to highlight such cases
> and most of the time remove any. However, there are some tests where a trailing whitespace
> is required and a critical part of the tests.
8 changes: 4 additions & 4 deletions docfx/ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ constructed a complete custom template to deal with it... Sigh, what a waste of
## Changes Over Time
DocFX has obsoleted the `docfxconsole` NuGet package that was used to run docfx for a
project via MSBUILD. Instead it focused on a .NET tool to do it all via the command line.
Ultimately the docfx.json serves as the corellary to a "project" file for the different site
Ultimately the docfx.json serves as the corollary to a "project" file for the different site
builds. The PowerShell script `Build-Docs.ps1` was updated to use the new tool directly.
Using that script should have little or no impact on the overall flow. There is a
"no-targets" project in the solution to enable easier access to the input files but does not
Expand Down Expand Up @@ -78,9 +78,9 @@ Since this is generated it is listed in the [.gitignore](#gitignore) file.
These folders (named after the `*` portion of the [api-*](#api-*) folder names contains
manually written additional files, articles, samples etc... related to a given library.

## Guide to wrting XML DOC comments
## Guide to writing XML DOC comments
When dealing with doc comments the XML can sometimes get in the way of general readability
of the source code. There is an inherent tension beween how a particular editor renders the
of the source code. There is an inherent tension between how a particular editor renders the
docs for a symbol/method (VS calls this "Quick Info") and how it is rendered in the final
documentation by a tool like docfx. This guides general use to simplify things as much as
possible.
Expand Down Expand Up @@ -144,7 +144,7 @@ render properly in final docs.
everything is trimmed it is at least a distinct pattern that is readable.
5) ***DO NOT*** put lists in any place other than inside a `remarks` region
a) Usually, the remarks comments are not even rendered in an editor as the most useful
part is the API signaure and parameter info. Different editors may allow control of
part is the API signature and parameter info. Different editors may allow control of
that.
i) In VS [2019|2022] for C# it is controlled by
`Text Editor > C# > Advanced > Editor Help: "Show remarks in Quick Info."`
Expand Down
8 changes: 4 additions & 4 deletions docfx/SrcGeneration/api/index.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Ubiquity.NET.SrcGeneration
This library contains support functionality to aid in building a source generator.
This library is multi-targetting to allow consumption from a Roslyn source generator
or VSIX project. Other uses should leverage the modern runtimes but those cases
***MUST*** target only `.NET Standard 2.0`
This library contains support functionality to aid in building a source generator. This
library is multi-targeting to allow consumption from a Roslyn source generator or VSIX
project. Other uses should leverage the modern runtimes but those cases ***MUST*** target
only `.NET Standard 2.0`

8 changes: 4 additions & 4 deletions docfx/SrcGeneration/index.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Ubiquity.NET.SrcGeneration
This library contains support functionality to aid in building a source generator.
This library is multi-targetting to allow consumption from a Roslyn source generator
or VSIX project. Other uses should leverage the modern runtimes but those cases
***MUST*** target only `.NET Standard 2.0`
This library contains support functionality to aid in building a source generator. This
library is multi-targeting to allow consumption from a Roslyn source generator or VSIX
project. Other uses should leverage the modern runtimes but those cases ***MUST*** target
only `.NET Standard 2.0`

2 changes: 1 addition & 1 deletion docfx/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ and versioning.
| [Ubiquity.NET.CommandLine](CommandLine/index.md) | This library contains extensions and helpers for command line parsing via `System.CommandLine` |
| [Ubiquity.NET.Extensions](extensions/index.md) | This library contains general extensions and helpers for many scenarios using .NET |
| [Ubiquity.NET.InteropHelpers](interop-helpers/index.md) | This library contains extensions and helpers for implementing interop support for native libraries |
| [Ubiquity.NET.Runtime.Utils](runtime-utils/index.md) | This library contains common support for DSL runtime and language implementors |
| [Ubiquity.NET.Runtime.Utils](runtime-utils/index.md) | This library contains common support for DSL runtime and language implementers |
| [Ubiquity.NET.SourceGenerator.Test.Utils](src-gen-test-utils/index.md) | This library contains extensions and helpers for testing source generators |
| [Ubiquity.NET.SrcGeneration](SrcGeneration/index.md) | This library contains extensions and helpers for implementing source generators |
10 changes: 5 additions & 5 deletions src/Ubiquity.NET.CodeAnalysis.Utils/CompilationExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.

// Mostly from: https://github.com/Sergio0694/PolySharp/blob/main/src/PolySharp.SourceGenerators/Extensions/CompilationExtensions.cs
// Reformated and adapted to support repo guidelines
// Reformatted and adapted to support repo guidelines

using Microsoft.CodeAnalysis.VisualBasic;

Expand Down Expand Up @@ -42,18 +42,18 @@ public static bool HasLanguageVersionAtLeastEqualTo( this Compilation compilatio

/// <summary>Gets the runtime version by extracting the version from the assembly implementing <see cref="System.Object"/></summary>
/// <param name="self">Compilation to get the version information from</param>
/// <returns>Version of the runtime the compilation is targetting</returns>
/// <returns>Version of the runtime the compilation is targeting</returns>
public static RuntimeVersion GetRuntimeVersion(this Compilation self)
{
var objectType = self.GetSpecialType(SpecialType.System_Object);
var runtimeAssembly = objectType.ContainingAssembly;
return new(runtimeAssembly.Identity.Name, runtimeAssembly.Identity.Version);
}

/// <summary>Gets a value indicating wheter the compilation has a minium version of the runtime</summary>
/// <summary>Gets a value indicating whether the compilation has a minium version of the runtime</summary>
/// <param name="self">Compilation to test</param>
/// <param name="minVersion">Minimum version accepted</param>
/// <returns><see langword="true"/> if the runtime version targetted by the compilation is at least <paramref name="minVersion"/>; <see langword="false"/> otherwise</returns>
/// <returns><see langword="true"/> if the runtime version targeted by the compilation is at least <paramref name="minVersion"/>; <see langword="false"/> otherwise</returns>
public static bool HasRuntimeVersionAtLeast(this Compilation self, RuntimeVersion minVersion)
{
var runtimeVersion = GetRuntimeVersion(self);
Expand Down Expand Up @@ -140,7 +140,7 @@ public static bool HasAccessibleMember( this Compilation compilation, string ful
/// <param name="memberName">Name of the member to test for</param>
/// <param name="within">Symbol to test if the member is accessible within</param>
/// <param name="throughType">Symbol to use for "protected access" [default: null]</param>
/// <returns><see langword="true"/> if the member is accesible and <see langword="false"/></returns>
/// <returns><see langword="true"/> if the member is accessible and <see langword="false"/></returns>
public static bool HasAccessibleMemberWithin(
this Compilation self,
ITypeSymbol typeSymbol,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ set of namespaces that is NOT consistent or controlled by the developer. THAT is

// BUG: False positive from IDE0005 - Using directive is unnecessary
// Attempts to remove/sort are at least able to figure it out and do the right thing.
// Bug seems to be related to multi-targetting.
// Bug seems to be related to multi-targeting.
#pragma warning disable IDE0005

global using System;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ from attribute in attributeList.Attributes
return value != null;
}

/// <summary>Determines if a declartion has an extern modifier</summary>
/// <summary>Determines if a declaration has an extern modifier</summary>
/// <param name="self"><see cref="MemberDeclarationSyntax"/> to test</param>
/// <returns><see langword="true"/> if <paramref name="self"/> has the modifier or <see langword="false"/> not</returns>
/// <exception cref="ArgumentNullException"><paramref name="self"/> is null</exception>
Expand All @@ -61,7 +61,7 @@ public static bool IsExtern(this MemberDeclarationSyntax self)
: throw new ArgumentNullException(nameof(self));
}

/// <summary>Determines if a declartion has a partial modifier</summary>
/// <summary>Determines if a declaration has a partial modifier</summary>
/// <inheritdoc cref="IsExtern(MemberDeclarationSyntax)"/>
public static bool IsPartial(this MemberDeclarationSyntax self)
{
Expand All @@ -70,7 +70,7 @@ public static bool IsPartial(this MemberDeclarationSyntax self)
: throw new ArgumentNullException(nameof(self));
}

/// <summary>Determines if a declartion has a static modifier</summary>
/// <summary>Determines if a declaration has a static modifier</summary>
/// <inheritdoc cref="IsExtern(MemberDeclarationSyntax)"/>
public static bool IsStatic(this MemberDeclarationSyntax self)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Ubiquity.NET.CodeAnalysis.Utils/NestedClassName.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public sealed class NestedClassName
/// <param name="keyword">Keyword for this declaration</param>
/// <param name="name">Name of the type</param>
/// <param name="constraints">Constraints for this type</param>
/// <param name="children">Names of any nested child types to form hiearachies</param>
/// <param name="children">Names of any nested child types to form hierarchies</param>
/// <remarks>
/// <paramref name="keyword"/> is normally one of ("class", "struct", "interface", "record [class|struct]?").
/// </remarks>
Expand Down
5 changes: 4 additions & 1 deletion src/Ubiquity.NET.CodeAnalysis.Utils/ReadMe.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# About
The Ubiquity.NET.CodeAnalysis.Utils contains support for building Roslyn analyzers, fixers,
and source generator.
and source generator. As such it specifically targets .NET Standard 2.0 and has no
dependencies on anything targeting a later runtime. If an analyzer (or any Roslyn extension)
depends on this package the dependencies for the package must be included in the extension's
package.
4 changes: 2 additions & 2 deletions src/Ubiquity.NET.CodeAnalysis.Utils/Result.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ public Result(T? value, ImmutableArray<DiagnosticInfo> diagnostics)
/// <summary>Report all diagnostics to the provided <paramref name="ctx"/></summary>
/// <param name="ctx"><see cref="SourceProductionContext"/> to report the diagnostics to</param>
/// <remarks>
/// This supports the deferral of reporting with a collection of cahceable <see cref="Result{T}"/>. This allows
/// for a generatr to report critical internal problems.
/// This supports the deferral of reporting with a collection of cacheable <see cref="Result{T}"/>. This allows
/// for a generator to report critical internal problems.
/// </remarks>
public void ReportDiagnostics(SourceProductionContext ctx)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public static void ReportDiagnostic( this SourceProductionContext self, Diagnost
/// <param name="self">The context to report the diagnostic to</param>
/// <param name="location">Location of the source of this diagnostic</param>
/// <param name="descriptor">Descriptor for the diagnostic</param>
/// <param name="messageArgs">Argumnets, if any, for the diagnostic message</param>
/// <param name="messageArgs">Arguments, if any, for the diagnostic message</param>
public static void ReportDiagnostic(
this SourceProductionContext self,
Location location,
Expand All @@ -61,7 +61,7 @@ params object[] messageArgs
/// <param name="self">The context to report the diagnostic to</param>
/// <param name="node">Node as the source of the diagnostic</param>
/// <param name="descriptor">Descriptor for the diagnostic</param>
/// <param name="messageArgs">Argumnets, if any, for the diagnostic message</param>
/// <param name="messageArgs">Arguments, if any, for the diagnostic message</param>
public static void ReportDiagnostic(
this SourceProductionContext self,
CSharpSyntaxNode node,
Expand Down
2 changes: 1 addition & 1 deletion src/Ubiquity.NET.CommandLine.UT/CommandLineTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public void CommandLine_parse_with_version_option_only_succeeds( )
var settings = CreateTestSettings();
var result = ArgsParsing.Parse<TestOptions>(["--version"], settings);

Assert.HasCount( 0, result.Errors, "Version alone should not procue errors" );
Assert.HasCount( 0, result.Errors, "Version alone should not produce errors" );

var versionOption = result.GetVersionOption();
Assert.IsNotNull(versionOption);
Expand Down
Loading
Loading