diff --git a/src/Interop/LlvmBindingsGenerator/CmdLineArgs.cs b/src/Interop/LlvmBindingsGenerator/CmdLineArgs.cs
index d07390d60..2dc695042 100644
--- a/src/Interop/LlvmBindingsGenerator/CmdLineArgs.cs
+++ b/src/Interop/LlvmBindingsGenerator/CmdLineArgs.cs
@@ -1,23 +1,18 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System.CommandLine.Parsing;
-using System.IO;
-
-using CppSharp;
-
namespace LlvmBindingsGenerator
{
internal partial class CmdLineArgs
{
// [Option("-l", Required=true, Description="Root of source with the LLVM headers to parse (Assumes and validates a sub-folder 'include')"]
// [AcceptExistingFolderOnly]
- // [Validator( "CmdLineArgs.ValidateIncludeFolder" )]
+ // [Validator( nameof(ValidateIncludeFolder) )]
public required DirectoryInfo LlvmRoot { get; init; }
// [Option("-e", Required=true, Description="Root of source with the LibLLVM extension headers to parse (Assumes and validates a sub-folder 'include')"]
// [AcceptExistingFolderOnly]
- // [Validator( "CmdLineArgs.ValidateIncludeFolder" )]
+ // [Validator( nameof(ValidateIncludeFolder) )]
public required DirectoryInfo ExtensionsRoot { get; init; }
// [Option("-e", Required=true, Description="Output to place the generated code for handles. No handle source is generated if this is not provided")]
diff --git a/src/Interop/LlvmBindingsGenerator/CmdLineArgs.g.cs b/src/Interop/LlvmBindingsGenerator/CmdLineArgs.g.cs
index aa36acfbf..06f75ccca 100644
--- a/src/Interop/LlvmBindingsGenerator/CmdLineArgs.g.cs
+++ b/src/Interop/LlvmBindingsGenerator/CmdLineArgs.g.cs
@@ -1,4 +1,7 @@
-using System;
+// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
+// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
+
+using System;
using System.Collections.Generic;
using System.CommandLine;
using System.CommandLine.Parsing;
@@ -45,7 +48,7 @@ public static AppControlledDefaultsRootCommand BuildRootCommand( CmdLineSettings
{
// description is hard coded and should come from generation attribute on the "CmdLineArgs" type
// TODO: Check for duplicate options.
- // (-?,-h, --help, and --version) are used by default options so nothing should use those values.
+ // (-?, -h, --help, and --version) are used by default options so nothing should use those values.
// Generator/analyzer should validate that so it isn't a runtime hit.
return new AppControlledDefaultsRootCommand( settings, "LLVM handle wrapper source generator" )
{
diff --git a/src/Interop/LlvmBindingsGenerator/Configuration/GeneratorConfig.cs b/src/Interop/LlvmBindingsGenerator/Configuration/GeneratorConfig.cs
index 02f9cbda7..4af9cd25b 100644
--- a/src/Interop/LlvmBindingsGenerator/Configuration/GeneratorConfig.cs
+++ b/src/Interop/LlvmBindingsGenerator/Configuration/GeneratorConfig.cs
@@ -1,8 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System.Collections.Immutable;
-
namespace LlvmBindingsGenerator.Configuration
{
internal class GeneratorConfig
diff --git a/src/Interop/LlvmBindingsGenerator/Configuration/HandleDetails.cs b/src/Interop/LlvmBindingsGenerator/Configuration/HandleDetails.cs
index 7ff609c2c..307929b25 100644
--- a/src/Interop/LlvmBindingsGenerator/Configuration/HandleDetails.cs
+++ b/src/Interop/LlvmBindingsGenerator/Configuration/HandleDetails.cs
@@ -1,8 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System.Diagnostics.CodeAnalysis;
-
namespace LlvmBindingsGenerator.Configuration
{
/// Details for a handle
diff --git a/src/Interop/LlvmBindingsGenerator/Configuration/IGeneratorConfig.cs b/src/Interop/LlvmBindingsGenerator/Configuration/IGeneratorConfig.cs
index 5d0338666..a96c87a63 100644
--- a/src/Interop/LlvmBindingsGenerator/Configuration/IGeneratorConfig.cs
+++ b/src/Interop/LlvmBindingsGenerator/Configuration/IGeneratorConfig.cs
@@ -1,13 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System.Collections.Generic;
-using System.Collections.Immutable;
-using System.Linq;
-
-using LlvmBindingsGenerator.CppSharpExtensions;
-using LlvmBindingsGenerator.Templates;
-
namespace LlvmBindingsGenerator.Configuration
{
/// Interface for a generator configuration
diff --git a/src/Interop/LlvmBindingsGenerator/CppSharpExtensions/ASTContextExtensions.cs b/src/Interop/LlvmBindingsGenerator/CppSharpExtensions/ASTContextExtensions.cs
index 8b0d9f3d0..55aaff99e 100644
--- a/src/Interop/LlvmBindingsGenerator/CppSharpExtensions/ASTContextExtensions.cs
+++ b/src/Interop/LlvmBindingsGenerator/CppSharpExtensions/ASTContextExtensions.cs
@@ -1,13 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System;
-using System.Collections.Generic;
-using System.Diagnostics.CodeAnalysis;
-using System.Linq;
-
-using CppSharp.AST;
-
namespace LlvmBindingsGenerator
{
internal static class ASTContextExtensions
diff --git a/src/Interop/LlvmBindingsGenerator/CppSharpExtensions/Driver.cs b/src/Interop/LlvmBindingsGenerator/CppSharpExtensions/Driver.cs
index 0d827b3e0..a0fa264b1 100644
--- a/src/Interop/LlvmBindingsGenerator/CppSharpExtensions/Driver.cs
+++ b/src/Interop/LlvmBindingsGenerator/CppSharpExtensions/Driver.cs
@@ -1,20 +1,8 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-
-using CppSharp;
-using CppSharp.AST;
-using CppSharp.Generators;
-using CppSharp.Parser;
-using CppSharp.Passes;
-using CppSharp.Types;
-using CppSharp.Utils;
-
using ClangParser = CppSharp.ClangParser;
+using Module = CppSharp.AST.Module;
namespace LlvmBindingsGenerator
{
diff --git a/src/Interop/LlvmBindingsGenerator/CppSharpExtensions/ErrorTrackingDiagnostics.cs b/src/Interop/LlvmBindingsGenerator/CppSharpExtensions/ErrorTrackingDiagnostics.cs
index b8a4d1a14..13eb165f3 100644
--- a/src/Interop/LlvmBindingsGenerator/CppSharpExtensions/ErrorTrackingDiagnostics.cs
+++ b/src/Interop/LlvmBindingsGenerator/CppSharpExtensions/ErrorTrackingDiagnostics.cs
@@ -1,10 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System;
-
-using CppSharp;
-
namespace LlvmBindingsGenerator
{
internal class ErrorTrackingDiagnostics
diff --git a/src/Interop/LlvmBindingsGenerator/CppSharpExtensions/FieldExtensions.cs b/src/Interop/LlvmBindingsGenerator/CppSharpExtensions/FieldExtensions.cs
index e2d3d247c..040b096a5 100644
--- a/src/Interop/LlvmBindingsGenerator/CppSharpExtensions/FieldExtensions.cs
+++ b/src/Interop/LlvmBindingsGenerator/CppSharpExtensions/FieldExtensions.cs
@@ -1,8 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using CppSharp.AST;
-
namespace LlvmBindingsGenerator
{
internal static class FieldExtensions
diff --git a/src/Interop/LlvmBindingsGenerator/CppSharpExtensions/ICodeGenerator.cs b/src/Interop/LlvmBindingsGenerator/CppSharpExtensions/ICodeGenerator.cs
index feedaa179..72f46566b 100644
--- a/src/Interop/LlvmBindingsGenerator/CppSharpExtensions/ICodeGenerator.cs
+++ b/src/Interop/LlvmBindingsGenerator/CppSharpExtensions/ICodeGenerator.cs
@@ -1,8 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using LlvmBindingsGenerator.CppSharpExtensions;
-
namespace LlvmBindingsGenerator
{
internal interface ICodeGenerator
diff --git a/src/Interop/LlvmBindingsGenerator/CppSharpExtensions/ICodeGeneratorTemplateFactory.cs b/src/Interop/LlvmBindingsGenerator/CppSharpExtensions/ICodeGeneratorTemplateFactory.cs
index f24bc5121..fd30d1001 100644
--- a/src/Interop/LlvmBindingsGenerator/CppSharpExtensions/ICodeGeneratorTemplateFactory.cs
+++ b/src/Interop/LlvmBindingsGenerator/CppSharpExtensions/ICodeGeneratorTemplateFactory.cs
@@ -1,9 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System.Collections.Generic;
-using CppSharp.Generators;
-
namespace LlvmBindingsGenerator
{
internal interface ICodeGeneratorTemplateFactory
diff --git a/src/Interop/LlvmBindingsGenerator/CppSharpExtensions/IDriver.cs b/src/Interop/LlvmBindingsGenerator/CppSharpExtensions/IDriver.cs
index cf50aba55..9c622bc23 100644
--- a/src/Interop/LlvmBindingsGenerator/CppSharpExtensions/IDriver.cs
+++ b/src/Interop/LlvmBindingsGenerator/CppSharpExtensions/IDriver.cs
@@ -1,13 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System;
-
-using CppSharp;
-using CppSharp.Generators;
-using CppSharp.Parser;
-using CppSharp.Passes;
-
namespace LlvmBindingsGenerator
{
internal interface IDriver
diff --git a/src/Interop/LlvmBindingsGenerator/CppSharpExtensions/ILibrary.cs b/src/Interop/LlvmBindingsGenerator/CppSharpExtensions/ILibrary.cs
index f28863e77..77b4a7dfd 100644
--- a/src/Interop/LlvmBindingsGenerator/CppSharpExtensions/ILibrary.cs
+++ b/src/Interop/LlvmBindingsGenerator/CppSharpExtensions/ILibrary.cs
@@ -1,10 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System.Collections.Generic;
-
-using CppSharp.AST;
-
namespace LlvmBindingsGenerator
{
internal interface ILibrary
diff --git a/src/Interop/LlvmBindingsGenerator/CppSharpExtensions/ITypePrinter2.cs b/src/Interop/LlvmBindingsGenerator/CppSharpExtensions/ITypePrinter2.cs
index 142714eae..212fee3e9 100644
--- a/src/Interop/LlvmBindingsGenerator/CppSharpExtensions/ITypePrinter2.cs
+++ b/src/Interop/LlvmBindingsGenerator/CppSharpExtensions/ITypePrinter2.cs
@@ -1,8 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using CppSharp.AST;
-
namespace LlvmBindingsGenerator
{
internal enum TypeNameKind
diff --git a/src/Interop/LlvmBindingsGenerator/CppSharpExtensions/NativeTypePrinter.cs b/src/Interop/LlvmBindingsGenerator/CppSharpExtensions/NativeTypePrinter.cs
index 6d376f4f3..e1708e418 100644
--- a/src/Interop/LlvmBindingsGenerator/CppSharpExtensions/NativeTypePrinter.cs
+++ b/src/Interop/LlvmBindingsGenerator/CppSharpExtensions/NativeTypePrinter.cs
@@ -1,12 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System;
-using System.Diagnostics.CodeAnalysis;
-using System.Text;
-
-using CppSharp.AST;
-
namespace LlvmBindingsGenerator
{
internal class NativeTypePrinter
diff --git a/src/Interop/LlvmBindingsGenerator/GlobalNamespaceImports.cs b/src/Interop/LlvmBindingsGenerator/GlobalNamespaceImports.cs
new file mode 100644
index 000000000..6a269c00c
--- /dev/null
+++ b/src/Interop/LlvmBindingsGenerator/GlobalNamespaceImports.cs
@@ -0,0 +1,40 @@
+// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
+// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
+
+/*
+NOTE:
+While the MsBuild `ImplicitUsings` property is banned from this repo, the C# language feature of global usings is NOT.
+The build property will auto include an invisible and undiscoverable (without looking up obscure documentation)
+set of namespaces that is NOT consistent or controlled by the developer. THAT is what is BAD/BROKEN about that feature.
+By banning it's use and then providing a `GlobalNamespaceImports.cs` source file with ONLY global using statements ALL of
+that is eliminated. Such use of the language feature restores FULL control and visibility of the namespaces to the developer,
+where it belongs. For a good explanation of this problem see: https://rehansaeed.com/the-problem-with-csharp-10-implicit-usings/.
+For an explanation of the benefits of the language feature see: https://www.hanselman.com/blog/implicit-usings-in-net-6
+*/
+
+global using System;
+global using System.Collections.Generic;
+global using System.Collections.Immutable;
+global using System.CommandLine.Parsing;
+global using System.Diagnostics.CodeAnalysis;
+global using System.IO;
+global using System.Linq;
+global using System.Reflection;
+global using System.Runtime.InteropServices;
+global using System.Text;
+
+global using CppSharp;
+global using CppSharp.AST;
+global using CppSharp.Generators;
+global using CppSharp.Generators.CSharp;
+global using CppSharp.Parser;
+global using CppSharp.Passes;
+global using CppSharp.Types;
+global using CppSharp.Utils;
+
+global using LlvmBindingsGenerator.Configuration;
+global using LlvmBindingsGenerator.CppSharpExtensions;
+global using LlvmBindingsGenerator.Passes;
+global using LlvmBindingsGenerator.Templates;
+
+global using Ubiquity.NET.CommandLine;
diff --git a/src/Interop/LlvmBindingsGenerator/GlobalSuppressions.cs b/src/Interop/LlvmBindingsGenerator/GlobalSuppressions.cs
index 2d285e46e..25e06e2f5 100644
--- a/src/Interop/LlvmBindingsGenerator/GlobalSuppressions.cs
+++ b/src/Interop/LlvmBindingsGenerator/GlobalSuppressions.cs
@@ -6,6 +6,4 @@
// a specific target and scoped to a namespace, type, member, etc.
*/
-using System.Diagnostics.CodeAnalysis;
-
[assembly: SuppressMessage( "", "SA0001: XML comment analysis is disabled due to project configuration", Justification = "Internal tool")]
diff --git a/src/Interop/LlvmBindingsGenerator/LibLLVMTypePrinter.cs b/src/Interop/LlvmBindingsGenerator/LibLLVMTypePrinter.cs
index 372a2644c..56fc4f60d 100644
--- a/src/Interop/LlvmBindingsGenerator/LibLLVMTypePrinter.cs
+++ b/src/Interop/LlvmBindingsGenerator/LibLLVMTypePrinter.cs
@@ -1,11 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System;
-
-using CppSharp.AST;
-using CppSharp.Generators.CSharp;
-
namespace LlvmBindingsGenerator
{
// CONSIDER: Make this type printer provide the source language name
diff --git a/src/Interop/LlvmBindingsGenerator/LibLlvmGeneratorLibrary.cs b/src/Interop/LlvmBindingsGenerator/LibLlvmGeneratorLibrary.cs
index 6a59c28cc..f76706e55 100644
--- a/src/Interop/LlvmBindingsGenerator/LibLlvmGeneratorLibrary.cs
+++ b/src/Interop/LlvmBindingsGenerator/LibLlvmGeneratorLibrary.cs
@@ -1,13 +1,7 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System.Collections.Generic;
-using System.IO;
-
-using CppSharp.AST;
-
-using LlvmBindingsGenerator.Configuration;
-using LlvmBindingsGenerator.Passes;
+using Type = CppSharp.AST.Type;
namespace LlvmBindingsGenerator
{
diff --git a/src/Interop/LlvmBindingsGenerator/LibLlvmTemplateFactory.cs b/src/Interop/LlvmBindingsGenerator/LibLlvmTemplateFactory.cs
index a57ef72d2..bc11a4788 100644
--- a/src/Interop/LlvmBindingsGenerator/LibLlvmTemplateFactory.cs
+++ b/src/Interop/LlvmBindingsGenerator/LibLlvmTemplateFactory.cs
@@ -1,16 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System.Collections.Generic;
-using System.Linq;
-
-using CppSharp;
-using CppSharp.Generators;
-using CppSharp.Passes;
-
-using LlvmBindingsGenerator.Configuration;
-using LlvmBindingsGenerator.CppSharpExtensions;
-
namespace LlvmBindingsGenerator
{
// Factory class for the templates needed in code generation
diff --git a/src/Interop/LlvmBindingsGenerator/Passes/IgnoreDuplicateNamesPass.cs b/src/Interop/LlvmBindingsGenerator/Passes/IgnoreDuplicateNamesPass.cs
index ffa42f1a2..6bc8e38d2 100644
--- a/src/Interop/LlvmBindingsGenerator/Passes/IgnoreDuplicateNamesPass.cs
+++ b/src/Interop/LlvmBindingsGenerator/Passes/IgnoreDuplicateNamesPass.cs
@@ -1,11 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System.Collections.Generic;
-
-using CppSharp.AST;
-using CppSharp.Passes;
-
namespace LlvmBindingsGenerator.Passes
{
/// Translation unit pass to mark duplicate function names as ignored
diff --git a/src/Interop/LlvmBindingsGenerator/Passes/IgnoreSystemHeadersPass.cs b/src/Interop/LlvmBindingsGenerator/Passes/IgnoreSystemHeadersPass.cs
index 81d727c03..2cc7df0b4 100644
--- a/src/Interop/LlvmBindingsGenerator/Passes/IgnoreSystemHeadersPass.cs
+++ b/src/Interop/LlvmBindingsGenerator/Passes/IgnoreSystemHeadersPass.cs
@@ -1,12 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System.Collections.Immutable;
-
-using CppSharp;
-using CppSharp.AST;
-using CppSharp.Passes;
-
namespace LlvmBindingsGenerator.Passes
{
/// Translation unit pass to mark system headers as ignored
diff --git a/src/Interop/LlvmBindingsGenerator/Passes/MarkFunctionsInternalPass.cs b/src/Interop/LlvmBindingsGenerator/Passes/MarkFunctionsInternalPass.cs
index a1de955d3..015bf0bcf 100644
--- a/src/Interop/LlvmBindingsGenerator/Passes/MarkFunctionsInternalPass.cs
+++ b/src/Interop/LlvmBindingsGenerator/Passes/MarkFunctionsInternalPass.cs
@@ -1,9 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using CppSharp.AST;
-using CppSharp.Passes;
-
namespace LlvmBindingsGenerator.Passes
{
/// Mark functions as internal or ignored
diff --git a/src/Interop/LlvmBindingsGenerator/Passes/ValidateExtensionNamingPass.cs b/src/Interop/LlvmBindingsGenerator/Passes/ValidateExtensionNamingPass.cs
index 8d2f16151..024f13d85 100644
--- a/src/Interop/LlvmBindingsGenerator/Passes/ValidateExtensionNamingPass.cs
+++ b/src/Interop/LlvmBindingsGenerator/Passes/ValidateExtensionNamingPass.cs
@@ -1,12 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System.Linq;
-
-using CppSharp;
-using CppSharp.AST;
-using CppSharp.Passes;
-
namespace LlvmBindingsGenerator.Passes
{
/// Translation unit pass to validate that names of all functions in the extension headers have correct prefix
diff --git a/src/Interop/LlvmBindingsGenerator/Program.cs b/src/Interop/LlvmBindingsGenerator/Program.cs
index 93f336507..be101ed37 100644
--- a/src/Interop/LlvmBindingsGenerator/Program.cs
+++ b/src/Interop/LlvmBindingsGenerator/Program.cs
@@ -1,13 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System;
-using System.Diagnostics.CodeAnalysis;
-
-using CppSharp;
-
-using Ubiquity.NET.CommandLine;
-
namespace LlvmBindingsGenerator
{
internal static partial class Program
diff --git a/src/Interop/LlvmBindingsGenerator/Properties/AssemblyInfo.cs b/src/Interop/LlvmBindingsGenerator/Properties/AssemblyInfo.cs
index 90a7af0d2..e0478b51a 100644
--- a/src/Interop/LlvmBindingsGenerator/Properties/AssemblyInfo.cs
+++ b/src/Interop/LlvmBindingsGenerator/Properties/AssemblyInfo.cs
@@ -1,10 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System;
-using System.Reflection;
-using System.Runtime.InteropServices;
-
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
diff --git a/src/Interop/LlvmBindingsGenerator/StringExtensions.cs b/src/Interop/LlvmBindingsGenerator/StringExtensions.cs
index 3f8eacc8e..8e231ac7b 100644
--- a/src/Interop/LlvmBindingsGenerator/StringExtensions.cs
+++ b/src/Interop/LlvmBindingsGenerator/StringExtensions.cs
@@ -1,8 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System.IO;
-
namespace LlvmBindingsGenerator
{
internal static class StringExtensions
diff --git a/src/Interop/LlvmBindingsGenerator/TemplateCodeGenerator.cs b/src/Interop/LlvmBindingsGenerator/TemplateCodeGenerator.cs
index 517038602..244fed32a 100644
--- a/src/Interop/LlvmBindingsGenerator/TemplateCodeGenerator.cs
+++ b/src/Interop/LlvmBindingsGenerator/TemplateCodeGenerator.cs
@@ -1,8 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using LlvmBindingsGenerator.CppSharpExtensions;
-
namespace LlvmBindingsGenerator
{
/// Adapter class from a generator to a CppSharp ICodeGenerator
diff --git a/src/Interop/LlvmBindingsGenerator/Templates/AssemblyExtensions.cs b/src/Interop/LlvmBindingsGenerator/Templates/AssemblyExtensions.cs
index 7d95ca022..0226845af 100644
--- a/src/Interop/LlvmBindingsGenerator/Templates/AssemblyExtensions.cs
+++ b/src/Interop/LlvmBindingsGenerator/Templates/AssemblyExtensions.cs
@@ -1,9 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System;
-using System.Reflection;
-
namespace LlvmBindingsGenerator.Templates
{
internal static class AssemblyExtensions
diff --git a/src/Interop/LlvmBindingsGenerator/Templates/WrappedHandleTemplate.cs b/src/Interop/LlvmBindingsGenerator/Templates/WrappedHandleTemplate.cs
index 3d7410123..4b883cd05 100644
--- a/src/Interop/LlvmBindingsGenerator/Templates/WrappedHandleTemplate.cs
+++ b/src/Interop/LlvmBindingsGenerator/Templates/WrappedHandleTemplate.cs
@@ -1,11 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System;
-
-using LlvmBindingsGenerator.Configuration;
-using LlvmBindingsGenerator.CppSharpExtensions;
-
namespace LlvmBindingsGenerator.Templates
{
// Manually maintained partial of the T4 Template generated type
diff --git a/src/Interop/Ubiquity.NET.Llvm.Interop/ABI/ReadMe.md b/src/Interop/Ubiquity.NET.Llvm.Interop/ABI/ReadMe.md
index 03d57dddf..7700d52d8 100644
--- a/src/Interop/Ubiquity.NET.Llvm.Interop/ABI/ReadMe.md
+++ b/src/Interop/Ubiquity.NET.Llvm.Interop/ABI/ReadMe.md
@@ -5,8 +5,8 @@ directly. The source generation was too problematic/complex to generalize to the
where the output was usable "as-is". Additionally, it used marshalling hints via a custom
YAML configuration file. Ultimately, this file ended up as a foreign language form of the
marshalling attributes in C# code. So it was mostly abandoned. (It is still used to generate
-the `EXPOORTS.g.def` file, the type specific handle wrappers, and perform some validations
-of the extension code at the native level.)
+the type specific handle wrappers, and perform some validations of the extension code at the
+native level.)
The generator did have one advantage in that it could read the configuration file AND
validate that the functions listed in it were still in the actual headers (though
@@ -21,35 +21,35 @@ ABI function pointers are represented as real .NET function pointers with an unm
signature.
### special consideration for handles
-LLVM handles are just value types that wrap around a runtime `nint` (basically
-a strong typedef for a pointer). Therefore, they are blittable value types and don't
-need any significant marshaling support. All LLVM handle managed projections **CANNOT**
-appear in the signature of an unmanaged function pointer as there is no way to mark
-the marshalling behavior for unmanaged pointers. Implementations of the "callbacks"
-MUST handle marshalling of the ABI types manually. Normally, they will leverage a
-`GCHandle` as the "context", perform marshalling, and forward the results on to the
-managed context object. But implementations are free to deal with things as they need
-to (or have to if no context parameter is available).
+LLVM handles are just value types that wrap around a runtime `nint` (basically a strong
+typedef for a pointer). Therefore, they are blittable value types and don't need any
+significant marshaling support. All LLVM handle managed projections **CANNOT** appear in the
+signature of an unmanaged function pointer as there is no way to mark the marshalling
+behavior for unmanaged pointers. Implementations of the "callbacks" MUST handle marshalling
+of the ABI types manually. Normally, they will leverage a `GCHandle` as the "context",
+perform marshalling, and forward the results on to the managed context object. But
+implementations are free to deal with things as they need to (or have to if no context
+parameter is available).
# General patterns for maintenance of P/Invoke signatures
The general pattern is that the interop APIs now ALL use the built-in interop source
generator via the `LibraryImportAttribute` this generates all the marshalling code at
-compile time so the result is AOT compatible. This is leveraged by the types generated
-for each LLVM handle type. Specifically, the default marshalling of handles ensures
-handle types are marshaled safely with `LibraryImportAttribute`. For the global
-handles that is the built-in support for `SafeHandle` derived type handling. For the
-context handles that is covered by the `ContextHandleMarshaller` custom marshalling
-type. The generated types for all context handles marks the type marshalling with the
-`NativeMarshallingAttribute` to ensure it is AOT marshalling ready.
+compile time so the result is AOT compatible. This is leveraged by the types generated for
+each LLVM handle type. Specifically, the default marshalling of handles ensures handle types
+are marshaled safely with `LibraryImportAttribute`. For the global handles that is the
+built-in support for `SafeHandle` derived type handling. For the context handles that is
+covered by the `ContextHandleMarshaller` custom marshalling type. The generated types for
+all context handles marks the type marshalling with the `NativeMarshallingAttribute` to
+ensure it is AOT marshalling ready.
## Arrays
-Array marshalling requires some careful annotation and interpretation from the native
-code where the type is normally just a pointer. There's nothing in the C/C++ language
-that says anything about the SIZE of the data that pointer points to beyond the size
-of the type pointed to. (i.e., Is `T*` a pointer to one element of type T, an array of
-elements of type `T`? If an array, how many such elements are valid...) Thus,
-marshalling to a runtime with stronger type guarantees requires some care. Reading the
-docs, and sometimes the source code of the implementation.
+Array marshalling requires some careful annotation and interpretation from the native code
+where the type is normally just a pointer. There's nothing in the C/C++ language that says
+anything about the SIZE of the data that pointer points to beyond the size of the type
+pointed to. (i.e., Is `T*` a pointer to one element of type T, an array of elements of type
+`T`? If an array, how many such elements are valid...) Thus, marshalling to a runtime with
+stronger type guarantees requires some care. Reading the docs, and sometimes the source code
+of the implementation.
### In Arrays
Input arrays are generally rather simple to declare and use the form:
@@ -64,79 +64,76 @@ filled in by the native code use the following pattern:
void LLVMSomeApiThatFillsArray(LLVMHandleOfSomeSort h, [Out] UInt32[] elements, int numElements);
```
-Arrays where the caller is expected to provide a pointer to valid (allocated, but
-likely uninitialized) data that is filled in by native code use the following pattern:
+Arrays where the caller is expected to provide a pointer to valid (allocated, but likely
+uninitialized) data that is filled in by native code use the following pattern:
``` C#
void LLVMSomeApiThatFillsArray(LLVMHandleOfSomeSort h, out UInt32[] elements, int numElements);
```
### Return arrays
-Return arrays are like an out param except that they are the return type. A problem
-with this is that they are **purely** `[Out]` in that the native code must allocate
-the return value and cleanup (if any) of that allocation is left to the caller to
-perform.
-
-It is important to note that `[Out] byte[] buf` and `out byte[] buf` are two very
-different declarations and have distinct meanings for the marshalling of these
-parameters. The first expects the **caller** to allocate the memory and it is 'filled
-in' by the callee, the second expects the **callee** to allocate and fill the memory.
-The second implies some form of "contract" on the release of the allocated memory. The
-normal marshaling has no knowledge of such a thing and does not know how to release it
-either. Thus, a custom marshaller is needed for such things.
+Return arrays are like an out param except that they are the return type. A problem with
+this is that they are **purely** `[Out]` in that the native code must allocate the return
+value and cleanup (if any) of that allocation is left to the caller to perform.
+
+It is important to note that `[Out] byte[] buf` and `out byte[] buf` are two very different
+declarations and have distinct meanings for the marshalling of these parameters. The first
+expects the **caller** to allocate the memory and it is 'filled in' by the callee, the
+second expects the **callee** to allocate and fill the memory. The second implies some form
+of "contract" on the release of the allocated memory. The normal marshaling has no knowledge
+of such a thing and does not know how to release it either. Thus, a custom marshaller is
+needed for such things.
#### Special support for SafeHandle arrays
-The built-in marshalling does NOT support arrays of SafeHandles as in parameters
-(retaining ownership [By const ref semantics]) so that is provided as extensions in
-the `Ubiquity.NET.InteropHelpers.RefHandleMarshaller` class.
+The built-in marshalling does NOT support arrays of SafeHandles as in parameters (retaining
+ownership [By const ref semantics]) so that is provided as extensions in the
+`Ubiquity.NET.InteropHelpers.RefHandleMarshaller` class.
## Explicit types
-All of the P/Invoke API signatures are created with Explicitly sized values for
-numerics ***and enumerations***. This ensures there is no confusion on the bit length
-of types etc... (For example, [U]Int[64|32|16] is ALWAYS used over any built-in
-wrappers to avoid any potential confusion about the size of types between C# and
-native C/C++)
+All of the P/Invoke API signatures are created with Explicitly sized values for numerics
+***and enumerations***. This ensures there is no confusion on the bit length of types etc...
+(For example, [U]Int[64|32|16] is ALWAYS used over any built-in alias to avoid potential
+confusion about the size of types between C# and native C/C++)
### Distinction for real LLVMBOOL vs Status
This library and P/Invoke signatures disambiguate between an actual boolean value
(`LLVMBool`) and what is really a success or failure status code. As with strings, the
-only way to tell the difference is to read the docs, or sometimes the source... Thus,
-for ALL API signatures an `LLVMStatus` is used for any native code signature `LLVMBool`
-that is documented as behaving like a status and NOT a bool. This prevents mass confusion
-on the intent and helps keep the API surface cleaner and more self documenting. (Does a
-non-zero `LLVMBool` mean it succeeded? Or does it mean there was an error?) Thus all APIs
-need a developer to understand the documentation and set the P/Invoke signature to use
+only way to tell the difference is to read the docs, or sometimes the source... Thus, for
+ALL API signatures an `LLVMStatus` is used for any native code signature `LLVMBool` that is
+documented as behaving like a status and NOT a bool. This prevents mass confusion on the
+intent and helps keep the API surface cleaner and more self documenting. (Does a non-zero
+`LLVMBool` mean it succeeded? Or does it mean there was an error?) Thus all of the interop
+APIs need a developer to understand the documentation and set the P/Invoke signature to use
`LLVMStatus` for anything that is really a status code and ***NOT*** a proper boolean
(true/false) value. This library has done that work and ALL signatures using the native
`LLVMBool` is manually evaluated and the correct form applied to the managed P/Invoke
signature.
## Enumerated value naming
-The normal rules of naming enumerated values are suspended for this low level interop
-API. The idea is to keep ALL enumeration names and values as close as possible (if not
-identical) to the underlying native code. This helps in supporting the idea that the
-documentation for the native code is relevant and easier to consume so that the
-documentation for this library focuses ONLY on the interop support provided within it.
+The normal rules of naming enumerated values are suspended for this low level interop API.
+The idea is to keep ALL enumeration names and values as close as possible (if not identical)
+to the underlying native code. This helps in supporting the idea that the documentation for
+the native code is relevant and easier to consume so that the documentation for this library
+focuses ONLY on the interop support provided within it.
## Calling convention
All of the P/Invoke APIs use an explicit
-`[UnmanagedCallConv(CallConvs=[typeof(CallConvCdecl)])]` to identify that the APIs use
-the standard "C" ABI calling convention. This is defined by the LLVM-C API.
+`[UnmanagedCallConv(CallConvs=[typeof(CallConvCdecl)])]` to identify that the APIs use the
+standard "C" ABI calling convention. This is defined by the LLVM-C API.
### Future optimization
-At some point in the future it might be worth adding the ability to suppress GC
-transitions as an optimization. Application of that requires great care and
-understanding of the GC and native implementation to ensure it is safe to do. This is
-strictly a performance optimization that has NO impact on callers so is left for
-future enhancement as applicable.
+At some point in the future it might be worth adding the ability to suppress GC transitions
+as an optimization. Application of that requires great care and understanding of the GC and
+native implementation to ensure it is safe to do. This is strictly a performance
+optimization that has NO impact on callers so is left for future enhancement as applicable.
## Special handling of strings
>[!NOTE]
> All native strings are assumed encoded as UTF8. This is the most common/compatible
> assumption to make. Sadly, LLVM itself is silent on the point.
-Since the handle types all have AOT marshalling support (built-in or generated) the
-APIs ALL use them directly. Leaving the only "tricky part" of strings. LLVM has come a
-long way and unified most string use to one of three forms.
+Since the handle types all have AOT marshalling support (built-in or generated) the APIs ALL
+use them directly. Leaving the only "tricky part" of strings. LLVM has come a long way and
+unified most string use to one of three forms.
1) Raw pointer aliases as a native string
1) These are owned by the implementation and assumed invalid after the container
@@ -148,52 +145,51 @@ long way and unified most string use to one of three forms.
#1 is handled by using `LazyEncodedString` which always makes a copy of the native data
These are ALWAYS copied from the native form at point of use. Thus any use of them will
-incur a performance hit as the memory is allocated/pinned, copied. This does, however,
-mean that there is no ambiguity about the validity or lifetime of an otherwise alias
-pointer. The built-in/BCL marshalling assumes that ALL native strings are allocated
-via `CoTaskMemAlloc()` and therefore require a release. But that is ***NEVER*** the
-case with LLVM and usually not true of interop with arbitrary C/C++ code.
+incur a performance hit as the memory is allocated/pinned, copied. This does, however, mean
+that there is no ambiguity about the validity or lifetime of an otherwise alias pointer. The
+built-in/BCL marshalling assumes that ALL native strings are allocated via `CoTaskMemAlloc()`
+and therefore require a release. But that is ***NEVER*** the case with LLVM and usually not
+true of interop with arbitrary C/C++ code.
#2 is handled by marking the occurrence with `MarshalUsing(typeof( DisposeMessageMarshaller )`
and a parameter or return signature of `LazyEncodedString`. (Or directly to `string'
if the results of the API is never expected in a call to a native API. Normally this
is only used for some form of `ToString` semantics API)
-#3 is handled similar to #2 except that it uses an internal handle type
-`ErrorMessageString`. This handle is internal as the ONLY use of such a string is from
-an `LLVMErrorRef` and the ownership semantics of such a thing are very unique. The
-LLVMErrorRef code will lazy initialize the `ErrorMessage` string to prevent any
-construction of the string in the native library until needed. Thus, all of the
-complexity is handled within the `LLVMErrorRef` type so that it is fairly easy and
-unsurprising to use from upper layers of managed code.
+#3 is handled similar to #2 except that it uses an internal handle type `ErrorMessageString`.
+This handle is internal as the ONLY use of such a string is from an `LLVMErrorRef` and the
+ownership semantics of the underlying string handle are ***very*** "strange". The
+`LLVMErrorRef` code will lazy initialize the `ErrorMessage` string to prevent any
+construction of the string in the native library until needed. Thus, all of the complexity
+is handled within the `LLVMErrorRef` type so that it is fairly easy and unsurprising to use
+from upper layers of managed code.
>[!IMPORTANT]
-> It is worth stressing the point here that there is NO WAY to know which string type
-> to use based on only the header files and API signatures they contain. One ***MUST***
-> read the documentation for the API to know (and occasionally dig into the source code,
-> as it often isn't documented what the requirements are!). This is one of the greatest
-> problems with any form of automated interop code generator. It can only scan the
-> headers and knows nothing about the documentation or intended semantics. This is why,
-> previously this was all done in a custom YAML file. But as this library and LLVM
-> grew that became unmaintainable and downright silly as it was basically just
-> describing the marshalling behavior in a foreign language. At best the tool could
-> generate anything where there is no potential for ambiguity and leave the rest
-> marked in a way a developer could find it. (The implementation in this repo has
-> chosen to ignore signatures for generation entirely so it is all maintained
-> "by hand" now)
+> It is worth stressing the point here that there is NO WAY to know which string type to use
+> based on only the header files and API signatures they contain. One ***MUST*** read the
+> documentation for the API to know (and occasionally dig into the source code, as it often
+> isn't documented what the requirements are!). This is one of the greatest problems with
+> any form of automated interop code generator. It can only scan the headers and knows
+> nothing about the documentation or intended semantics. This is why, previously this was
+> all done in a custom YAML file. But as this library and LLVM grew that became
+> unmaintainable and downright silly as it was basically just describing the marshalling
+> behavior in a foreign language. At best the tool could generate anything where there is no
+> potential for ambiguity and leave the rest marked in a way a developer could find it. (The
+> implementation in this repo has chosen to ignore signatures for generation entirely so it
+> is all maintained "by hand" now)
### String lengths
-Sadly, the LLVM-C API is across the map on types used for the length of a string in
-the `C` APIs. It is any one of `size_t, int, unsigned`. That is, there is no consistent
-standard on that point. Thus, the interop code deals with things as `size_t` and
-downcasts with `checked()` to ensure conversion failures trigger an exception. Since,
-`size_t` is NOT hard defined to any particular size by the language `nuint` is used
-as the size of a native pointer is generally equivalent.^1^
+Sadly, the LLVM-C API is across the map on types used for the length of a string in the `C`
+APIs. It is any one of `size_t, int, unsigned`. That is, there is no consistent standard on
+that point in LLVM-C. Thus, the interop code deals with things as `size_t` and downcasts
+with `checked()` to ensure conversion failures trigger an exception. Since, `size_t` is NOT
+hard defined to any particular size by the language `nuint` is used as the size of a native
+pointer is generally equivalent.^1^
#### APIs accepting a length for a String
-APIs that accept a string are wrapped at the interop layer using `LazyEncodedString`
-where the length is provided by the wrapper so callers don't need to worry about it.
-Generally this takes the form like in the following example:
+APIs that accept a string are wrapped at the interop layer using `LazyEncodedString` where
+the length is provided by the wrapper so callers don't need to worry about it. Generally,
+this takes the form like in the following example:
``` C#
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static uint LLVMGetSyncScopeID(LLVMContextRefAlias C, LazyEncodedString Name)
@@ -209,11 +205,11 @@ private static unsafe partial uint LLVMGetSyncScopeID(LLVMContextRefAlias C, Laz
> The imported API is declared as private because a local `partial` function is NOT
> allowed in the language.
-Sometimes an API will return a pointer AND include an out parameter for the length
-of a string. These require great care as they do NOT guarantee that the string is
-terminated! Only that the length is valid. Thus, the implementation of wrappers for
-such APIs follow a pattern of hiding the length out parameter to produce a
-`LazyEncodedString` as in the following example:
+Sometimes an API will return a pointer AND include an out parameter for the length of a
+string. These require great care as they do NOT guarantee that the string is terminated!
+Only that the length is valid. Thus, the implementation of wrappers for such APIs follow a
+pattern of hiding the length out parameter to produce a `LazyEncodedString` as in the
+following example:
``` C#
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -231,17 +227,17 @@ public static LazyEncodedString LLVMGetStringAttributeKind(LLVMAttributeRef A)
private static unsafe partial byte* LLVMGetStringAttributeKind(LLVMAttributeRef A, out uint Length);
```
>[!IMPORTANT]
-> It is very tempting to simply ignore the out length and assume the returned pointer
-> is for a terminated string. Most of the time it will be, but some times it isn't!
-> There are no guarantees either way. Thus, the implementation of this library will
-> handle the subtleties and provide a `LazyEncodedString` from the pointer and length.
+> It is very tempting to simply ignore the out length and assume the returned pointer is for
+> a terminated string. Most of the time it will be, but some times it isn't! There are no
+> guarantees either way. Thus, the implementation of this library will handle the subtleties
+> and provide a `LazyEncodedString` from the pointer and length.
>[!IMPORTANT]
-> It is also tempting to blindly cast the length to the `int` needed for a span and
-> that will mostly work - until it doesn't, and then all hell breaks lose with weird
-> and difficult to track behavior. By applying a `checked()` to the conversions ANY
-> overflows are caught and triggered at the point of the problem. It is unlikely these
-> will ever hit as strings that large are generally unmanageable at runtime anyway.
+> It is also tempting to blindly cast the length to the `int` needed for a span and that
+> will mostly work - until it doesn't, and then all hell breaks lose with weird and
+> difficult to track behavior. By applying a `checked()` to the conversions ANY overflows
+> are caught and triggered at the point of the problem. It is unlikely these will ever hit
+> as strings that large are generally unmanageable at runtime anyway.
---
^1^ While it is plausible to create an ISO `C` compliant compiler implementation and
diff --git a/src/Interop/Ubiquity.NET.Llvm.Interop/ABI/StringMarshaling/LLVMErrorRef.cs b/src/Interop/Ubiquity.NET.Llvm.Interop/ABI/StringMarshaling/LLVMErrorRef.cs
index 8d64ecfb9..66a22c84a 100644
--- a/src/Interop/Ubiquity.NET.Llvm.Interop/ABI/StringMarshaling/LLVMErrorRef.cs
+++ b/src/Interop/Ubiquity.NET.Llvm.Interop/ABI/StringMarshaling/LLVMErrorRef.cs
@@ -1,8 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using static Ubiquity.NET.Llvm.Interop.ABI.llvm_c.Error;
-
namespace Ubiquity.NET.Llvm.Interop.ABI.StringMarshaling
{
/// Global LLVM object handle for an error
diff --git a/src/Interop/Ubiquity.NET.Llvm.Interop/GlobalNamespaceImports.cs b/src/Interop/Ubiquity.NET.Llvm.Interop/GlobalNamespaceImports.cs
index 732d3208b..2f299d9ca 100644
--- a/src/Interop/Ubiquity.NET.Llvm.Interop/GlobalNamespaceImports.cs
+++ b/src/Interop/Ubiquity.NET.Llvm.Interop/GlobalNamespaceImports.cs
@@ -18,17 +18,27 @@ set of namespaces that is NOT consistent or controlled by the developer. THAT is
global using System.Diagnostics.CodeAnalysis;
global using System.Globalization;
global using System.IO;
+global using System.Linq;
global using System.Reflection;
global using System.Runtime.CompilerServices;
global using System.Runtime.InteropServices;
global using System.Runtime.InteropServices.Marshalling;
global using System.Threading;
+global using Ubiquity.NET.Extensions;
global using Ubiquity.NET.InteropHelpers;
global using Ubiquity.NET.Llvm.Interop.ABI.libllvm_c;
global using Ubiquity.NET.Llvm.Interop.ABI.llvm_c;
global using Ubiquity.NET.Llvm.Interop.ABI.StringMarshaling;
global using Ubiquity.NET.Llvm.Interop.Properties;
+global using Ubiquity.NET.Versioning;
+
+global using static Ubiquity.NET.Llvm.Interop.ABI.libllvm_c.OrcJITv2Bindings;
+global using static Ubiquity.NET.Llvm.Interop.ABI.libllvm_c.TargetRegistrationBindings;
+global using static Ubiquity.NET.Llvm.Interop.ABI.libllvm_c.ValueBindings;
+global using static Ubiquity.NET.Llvm.Interop.ABI.llvm_c.Core;
+global using static Ubiquity.NET.Llvm.Interop.ABI.llvm_c.Error;
+global using static Ubiquity.NET.Llvm.Interop.ABI.llvm_c.ErrorHandling;
// global using for the NativeMethods type to allow simpler access to the
// string const for the library name.
diff --git a/src/Interop/Ubiquity.NET.Llvm.Interop/ILibLlvm.cs b/src/Interop/Ubiquity.NET.Llvm.Interop/ILibLlvm.cs
index 17aabc48a..1015c9606 100644
--- a/src/Interop/Ubiquity.NET.Llvm.Interop/ILibLlvm.cs
+++ b/src/Interop/Ubiquity.NET.Llvm.Interop/ILibLlvm.cs
@@ -1,8 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using Ubiquity.NET.Versioning;
-
namespace Ubiquity.NET.Llvm.Interop
{
/// Interface to the core LLVM library itself
diff --git a/src/Interop/Ubiquity.NET.Llvm.Interop/LLVMValueRefExtensions.cs b/src/Interop/Ubiquity.NET.Llvm.Interop/LLVMValueRefExtensions.cs
index d08110be3..b1bd5ed4d 100644
--- a/src/Interop/Ubiquity.NET.Llvm.Interop/LLVMValueRefExtensions.cs
+++ b/src/Interop/Ubiquity.NET.Llvm.Interop/LLVMValueRefExtensions.cs
@@ -1,8 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using static Ubiquity.NET.Llvm.Interop.ABI.libllvm_c.ValueBindings;
-
namespace Ubiquity.NET.Llvm.Interop
{
// This does NOT use the new C# 14 extension syntax due to several reasons
diff --git a/src/Interop/Ubiquity.NET.Llvm.Interop/Library.cs b/src/Interop/Ubiquity.NET.Llvm.Interop/Library.cs
index d78aabcd9..b8909b3da 100644
--- a/src/Interop/Ubiquity.NET.Llvm.Interop/Library.cs
+++ b/src/Interop/Ubiquity.NET.Llvm.Interop/Library.cs
@@ -1,12 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using Ubiquity.NET.Versioning;
-
-using static Ubiquity.NET.Llvm.Interop.ABI.libllvm_c.TargetRegistrationBindings;
-using static Ubiquity.NET.Llvm.Interop.ABI.llvm_c.Core;
-using static Ubiquity.NET.Llvm.Interop.ABI.llvm_c.ErrorHandling;
-
namespace Ubiquity.NET.Llvm.Interop
{
/// Provides support for various LLVM static state initialization and manipulation
diff --git a/src/Interop/Ubiquity.NET.Llvm.Interop/SymbolStringPoolEntryRefExtension.cs b/src/Interop/Ubiquity.NET.Llvm.Interop/SymbolStringPoolEntryRefExtension.cs
index 62f8d37a2..50f3d878f 100644
--- a/src/Interop/Ubiquity.NET.Llvm.Interop/SymbolStringPoolEntryRefExtension.cs
+++ b/src/Interop/Ubiquity.NET.Llvm.Interop/SymbolStringPoolEntryRefExtension.cs
@@ -1,8 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using Ubiquity.NET.Extensions;
-
namespace Ubiquity.NET.Llvm.Interop
{
// This does NOT use the new C# 14 extension syntax due to several reasons
diff --git a/src/Interop/Ubiquity.NET.Llvm.Interop/SymbolStringPoolExtension.cs b/src/Interop/Ubiquity.NET.Llvm.Interop/SymbolStringPoolExtension.cs
index 7a3741a01..24b6f5944 100644
--- a/src/Interop/Ubiquity.NET.Llvm.Interop/SymbolStringPoolExtension.cs
+++ b/src/Interop/Ubiquity.NET.Llvm.Interop/SymbolStringPoolExtension.cs
@@ -1,10 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System.Linq;
-
-using static Ubiquity.NET.Llvm.Interop.ABI.libllvm_c.OrcJITv2Bindings;
-
namespace Ubiquity.NET.Llvm.Interop
{
// This does NOT use the new C# 14 extension syntax due to several reasons
diff --git a/src/Interop/readme-first.md b/src/Interop/readme-first.md
index 15f4b8e42..1be5ddca0 100644
--- a/src/Interop/readme-first.md
+++ b/src/Interop/readme-first.md
@@ -5,35 +5,42 @@ library, which is, currently^1^, a dependency of the LLVM wrapper library.
# OBSOLECENSE NOTE
Most of the functionality of this tool for generating the interop API signatures was gutted
-and removed. It fell into the "good idea at the time" category. But in reality turned out to
+and removed. It fell into the "good idea at the time" category. In reality it turned out to
be a greater PITA than worth. The source code committed to the repo now includes the C#
interop code so this generator is not needed for most of that. It **IS** still used for the
following scenarios:
* To generate the source for the handle types.
- These types are very tedious and repetitive which is the perfect use of some form of
template
- - Global handles are mostly covered in the `GlobalHandleBase` class
- - Context handles are all `readonly record` types that wrap a native integer so have
- more to generate.
- - In the future when .NET 10 is available as Long Term Support (LTS) these may
- change to a `ref` struct so that the compiler can validate usage as never stored.
- They are not currently using that as they also need to support the
- `IContextHandle` interface for marshalling. `allows ref struct` is ONLY
- available in .NET 9 which only has Short Term Support (STS).
+ - All Handle kinds structs that are simple type safe wrappers around an `nint`
+ - Global handles all implement `IDisposable` to make disposal consistent.
+ - They are still immutable types and the use of IDisposable is simply to unify
+ the disposal and leverage built-in patterns for ownership. Since these are
+ immutable types the `Dispose()` is NOT idempotent.
+ - This is normally not an issue as this is NOT inteded for exposire to end users.
+ It is expected that the handles are wrapped in an OO type that can replace the
+ handle held with a default value on Dispose() to allow for an idempotent
+ dispose.
+ - Idempotent dispose is useful for APIs that use `move` semantics where the
+ native API takes over ownership, but only on success. Thus, a caller might
+ still own the resource on error/exception. By allowing idempotent `Dispose`
+ the caller need not care about such subtlties and ALWAYS calls `Dispose`
+ which is normally a NOP, but if an error occured actually releases the
+ resource.
## Roslyn Source Generators - 'There be dragons there!'
Roslyn allows source generators directly in the compiler making for a feature similar to C++
-template code generation AT compile time. However, there's a couple of BIG issue with that
+template code generation AT compile time. However, there's a couple of BIG issues with that
for this particular code base.
1) Non-deterministic ordering, or more specifically no way to declare the dependency on
outputs of one generator as the input for another.
2) Dependencies for project references
- - The generators are not general purpose they are not published or produced as a NUGET
- package. They only would be of use as a project reference. But that creates a TON of
- problems for the binary runtime dependencies of source generators, which don't flow
- with them as project references...
+ - The generators are not general purpose so they are not published or produced as a
+ NUGET package. They only would be of use as a project reference. But that creates a
+ TON of problems for the binary runtime dependencies of source generators, which don't
+ flow with them as project references...
-Specifically, in this code, the built-in generator that otherwise knows noting about the
+Specifically, in this code, the built-in generator, which otherwise knows nothing about the
handle generation, needs to see and use the **OUTPUT** of the handle source generation.
(It's not just a run ordering problem as ALL generators see the same input text!)
[See: [Discussion on ordering and what a generator "sees"](https://github.com/dotnet/roslyn/discussions/57912#discussioncomment-1682779)
@@ -66,7 +73,7 @@ correct code.
### Alternate solutions considered and rejected
1) Running the source generator directly in the project
1) This is where the problem on non-deterministic ordering and visibility of the
- generated code was discovered. Obviously (now anyway!) this won't work.
+ generated code was discovered. Obviously, (now anyway!) this won't work.
2) Use a source generator in a separate assembly
1) This solves the generator output dependency problem but introduces a new problem of
how the build infrastructure for these types manage NuGet versions.
@@ -79,13 +86,18 @@ correct code.
2) However, this runs afoul of the binary dependency problem... Not 100% insurmountable
but the number of caveats on the Roslyn Source Generator side of things grows to a
significant factor. This makes it more trouble than it's worth.
+4) Mark each call site with `MarhalUsing` so that it is explicit at the call site instead
+ of needing a source generator.
+ 1) This can work, however it means a great deal of tedious attribution that the
+ compilation should do for us.
+ 1) Elimination of tedious typing and repetive code is WHY templates/generics exist.
### The final choice
-Keep using this library as a generator for the handle types. This used to work, and still
-does. However, this doesn't solve the problem of expressing managed code things in a custom
-language (YAML) but it's at least a rather simplistic expression for the handles. And,
-arguably, less complicated then all the subtleties of using a Roslyn Source generator for
-this sort of one off specialized code generation.
+Keep using `LlvmBindingsGenerator` as a generator for the handle types. This used to work,
+and still does. However, this doesn't solve the problem of expressing managed code things in
+a custom language (YAML) but it's at least a rather simplistic expression for the handles.
+And, arguably, less complicated then all the subtleties of using a Roslyn Source generator
+for this sort of one off specialized code generation.
This also keeps the door open to use the native AST from within the source generator or an
analyzer to perform additional checks and ensure the hand written code matches the actual
@@ -95,8 +107,8 @@ may be best to generate an input to a proper analyzer)
## Projects
### LlvmBindingsGenerator
This is the P/Invoke generator for the handle wrappers in Ubiquity.NET.Llvm.Interop. It uses
-`CppSharp` to parse the C or C++ headers and generate wrappers for all the handles in the
-native library (Global, Context, and global aliased).
+`CppSharp` to parse the C consumable headers and generate wrappers for all the handles in
+the native library (Global, Context, and global aliased).
#### Usage
`LlvmBindingsGenerator -l -e [-o ]`
@@ -108,13 +120,10 @@ native library (Global, Context, and global aliased).
| InputPath | Root directory containing the "GlobalHandles.cs" and "ContextHandles.cs" files to generate the backing implementation for
| OutputPath | This is the root of the location to generate the output into, normally this is the "GeneratedCode" sub folder of the Ubiquity.NET.Llvm.Interop project so the files are generated into the project |
-This tool is generally only required once per Major LLVM release. (Though a Minor release
-that adds new APIs would also warrant a new run) However, to ensure the code generation tool
-itself isn't altered with a breaking change, the PowerShell script takes care of running the
-generator to update the Ubiquity.NET.Llvm.Interop code base on each run, even if nothing
-changes in the end. This is run on every automated build before building the
-`Ubiquity.NET.Llvm.Interop` project so that the generator is tested on every full automated
-build.
+This tool is generally only required once per Major LLVM release. It is run locally and the
+resulting generated code is checked in. This is due to a limitation of the `CppSharp`
+dependency. It only supports `x64` targets and this assembly is intended for use with any
+RID supported by .NET (and the underlying LLVM) ^2^
### Ubiquity.NET.Llvm.Interop
This is the .NET P/Invoke layer that provides the raw API projection to .NET. The, majority
@@ -127,8 +136,8 @@ dependency on the native LibLLVM binary there is no compile time dependency.
There are some general steps that are required to successfully build the interop NuGet
package and a couple of different ways to go about completing them.
1. Build LlvmBindingsGenerator
- 2. Run LlvmBindingsGenerator to parse the llvm headers and the extended headers from the
- native LibLLVM.
+2. Run LlvmBindingsGenerator to parse the llvm headers and the extended headers from the
+ native LibLLVM.
1. This generates the C# interop code AND the linker DEF file used by the native library
and therefore needs to run before the other projects are built.
1. Generating the exports file ensures that it is always accurate and any functions
@@ -157,5 +166,8 @@ or library should release with that as a dependency (except transitively from th
as it may not exist in the future
:warning: You have been warned! :warning:
+^2^ Currently ONLY win-x64 is supported but the foundational work is present to allow
+building for other platorms.
+
diff --git a/src/Ubiquity.NET.ANTLR.Utils/AntlrParseErrorListenerAdapter.cs b/src/Ubiquity.NET.ANTLR.Utils/AntlrParseErrorListenerAdapter.cs
index 42cb2fafe..a9c63ae0f 100644
--- a/src/Ubiquity.NET.ANTLR.Utils/AntlrParseErrorListenerAdapter.cs
+++ b/src/Ubiquity.NET.ANTLR.Utils/AntlrParseErrorListenerAdapter.cs
@@ -1,16 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System;
-using System.Collections.Immutable;
-using System.IO;
-
-using Antlr4.Runtime;
-using Antlr4.Runtime.Misc;
-
-using Ubiquity.NET.Extensions;
-using Ubiquity.NET.Runtime.Utils;
-
namespace Ubiquity.NET.ANTLR.Utils
{
/// Adapter to translate ANTLR error listeners to an
diff --git a/src/Ubiquity.NET.ANTLR.Utils/AntlrUtilities.cs b/src/Ubiquity.NET.ANTLR.Utils/AntlrUtilities.cs
index 701d59e29..7187c5c89 100644
--- a/src/Ubiquity.NET.ANTLR.Utils/AntlrUtilities.cs
+++ b/src/Ubiquity.NET.ANTLR.Utils/AntlrUtilities.cs
@@ -1,17 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System;
-using System.Collections.Generic;
-using System.Globalization;
-using System.Text;
-
-using Antlr4.Runtime;
-using Antlr4.Runtime.Misc;
-using Antlr4.Runtime.Tree;
-
-using static System.Math;
-
namespace Ubiquity.NET.ANTLR.Utils
{
/// Utility functions for extending ANTLR types
@@ -33,7 +22,7 @@ public static Interval GetCharInterval( this ParserRuleContext ruleContext )
int startChar = ruleContext.Start.StartIndex;
int endChar = ruleContext.Stop.StopIndex - 1;
- return Interval.Of( Min( startChar, endChar ), Max( startChar, endChar ) );
+ return Interval.Of( Math.Min( startChar, endChar ), Math.Max( startChar, endChar ) );
}
/// Gets the source from a recognizer if it is available
diff --git a/src/Ubiquity.NET.ANTLR.Utils/DebugTraceListener.cs b/src/Ubiquity.NET.ANTLR.Utils/DebugTraceListener.cs
index f4a9a50a2..6757e34eb 100644
--- a/src/Ubiquity.NET.ANTLR.Utils/DebugTraceListener.cs
+++ b/src/Ubiquity.NET.ANTLR.Utils/DebugTraceListener.cs
@@ -1,12 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System;
-using System.Diagnostics;
-
-using Antlr4.Runtime;
-using Antlr4.Runtime.Tree;
-
namespace Ubiquity.NET.ANTLR.Utils
{
/// Provides debug notification of all rule processing while parsing
diff --git a/src/Ubiquity.NET.ANTLR.Utils/GlobalNamespaceImports.cs b/src/Ubiquity.NET.ANTLR.Utils/GlobalNamespaceImports.cs
new file mode 100644
index 000000000..2a699c844
--- /dev/null
+++ b/src/Ubiquity.NET.ANTLR.Utils/GlobalNamespaceImports.cs
@@ -0,0 +1,28 @@
+// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
+// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
+
+/*
+NOTE:
+While the MsBuild `ImplicitUsings` property is banned from this repo, the C# language feature of global usings is NOT.
+The build property will auto include an invisible and undiscoverable (without looking up obscure documentation)
+set of namespaces that is NOT consistent or controlled by the developer. THAT is what is BAD/BROKEN about that feature.
+By banning it's use and then providing a `GlobalNamespaceImports.cs` source file with ONLY global using statements ALL of
+that is eliminated. Such use of the language feature restores FULL control and visibility of the namespaces to the developer,
+where it belongs. For a good explanation of this problem see: https://rehansaeed.com/the-problem-with-csharp-10-implicit-usings/.
+For an explanation of the benefits of the language feature see: https://www.hanselman.com/blog/implicit-usings-in-net-6
+*/
+
+global using System;
+global using System.Collections.Generic;
+global using System.Collections.Immutable;
+global using System.Diagnostics;
+global using System.Globalization;
+global using System.IO;
+global using System.Text;
+
+global using Antlr4.Runtime;
+global using Antlr4.Runtime.Misc;
+global using Antlr4.Runtime.Tree;
+
+global using Ubiquity.NET.Extensions;
+global using Ubiquity.NET.Runtime.Utils;
diff --git a/src/Ubiquity.NET.ANTLR.Utils/LocationExtensions.cs b/src/Ubiquity.NET.ANTLR.Utils/LocationExtensions.cs
index 18d0a2410..de1ca1cff 100644
--- a/src/Ubiquity.NET.ANTLR.Utils/LocationExtensions.cs
+++ b/src/Ubiquity.NET.ANTLR.Utils/LocationExtensions.cs
@@ -1,13 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System;
-
-using Antlr4.Runtime;
-using Antlr4.Runtime.Tree;
-
-using Ubiquity.NET.Extensions;
-
namespace Ubiquity.NET.ANTLR.Utils
{
/// Utility class to provide extensions for translation of ANTLR location data into a
diff --git a/src/Ubiquity.NET.CommandLine/AppControlledDefaultsRootCommand.cs b/src/Ubiquity.NET.CommandLine/AppControlledDefaultsRootCommand.cs
index 0b358973f..a78573455 100644
--- a/src/Ubiquity.NET.CommandLine/AppControlledDefaultsRootCommand.cs
+++ b/src/Ubiquity.NET.CommandLine/AppControlledDefaultsRootCommand.cs
@@ -1,12 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System;
-using System.CommandLine;
-using System.CommandLine.Help;
-using System.Diagnostics.CodeAnalysis;
-using System.Linq;
-
namespace Ubiquity.NET.CommandLine
{
/// Extension of that allows app control of defaults that are otherwise forced
diff --git a/src/Ubiquity.NET.CommandLine/ArgsParsing.cs b/src/Ubiquity.NET.CommandLine/ArgsParsing.cs
index 12b992c82..2cd342c48 100644
--- a/src/Ubiquity.NET.CommandLine/ArgsParsing.cs
+++ b/src/Ubiquity.NET.CommandLine/ArgsParsing.cs
@@ -1,12 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System.CommandLine;
-using System.CommandLine.Help;
-using System.CommandLine.Invocation;
-using System.Diagnostics.CodeAnalysis;
-using System.Globalization;
-
namespace Ubiquity.NET.CommandLine
{
/// Results of invoking the default handlers for or
diff --git a/src/Ubiquity.NET.CommandLine/ArgumentExceptionReporter.cs b/src/Ubiquity.NET.CommandLine/ArgumentExceptionReporter.cs
index 754b970f9..b46f70b4b 100644
--- a/src/Ubiquity.NET.CommandLine/ArgumentExceptionReporter.cs
+++ b/src/Ubiquity.NET.CommandLine/ArgumentExceptionReporter.cs
@@ -1,9 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System;
-using System.Text;
-
namespace Ubiquity.NET.CommandLine
{
/// Implementation of that throws for any errors reported.
diff --git a/src/Ubiquity.NET.CommandLine/CmdLineSettings.cs b/src/Ubiquity.NET.CommandLine/CmdLineSettings.cs
index 051a821d9..5eb446679 100644
--- a/src/Ubiquity.NET.CommandLine/CmdLineSettings.cs
+++ b/src/Ubiquity.NET.CommandLine/CmdLineSettings.cs
@@ -1,11 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System;
-using System.CommandLine;
-using System.CommandLine.Completions;
-using System.CommandLine.Parsing;
-
namespace Ubiquity.NET.CommandLine
{
/// Flags to determine the default Options for an
diff --git a/src/Ubiquity.NET.CommandLine/ColoredConsoleReporter.cs b/src/Ubiquity.NET.CommandLine/ColoredConsoleReporter.cs
index 86297fdbf..ec2c10061 100644
--- a/src/Ubiquity.NET.CommandLine/ColoredConsoleReporter.cs
+++ b/src/Ubiquity.NET.CommandLine/ColoredConsoleReporter.cs
@@ -1,14 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System;
-using System.Collections.Immutable;
-using System.Diagnostics.CodeAnalysis;
-
-using AnsiCodes;
-
-using Ubiquity.NET.Extensions;
-
namespace Ubiquity.NET.CommandLine
{
/// Implementation of that uses colorized console output
diff --git a/src/Ubiquity.NET.CommandLine/ConsoleReporter.cs b/src/Ubiquity.NET.CommandLine/ConsoleReporter.cs
index 6948f9496..bfea22793 100644
--- a/src/Ubiquity.NET.CommandLine/ConsoleReporter.cs
+++ b/src/Ubiquity.NET.CommandLine/ConsoleReporter.cs
@@ -1,9 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System;
-using System.Diagnostics.CodeAnalysis;
-
namespace Ubiquity.NET.CommandLine
{
/// Implementation of that reports messages to a
diff --git a/src/Ubiquity.NET.CommandLine/DiagnosticMessage.cs b/src/Ubiquity.NET.CommandLine/DiagnosticMessage.cs
index 03ff4308e..bf3c6eb51 100644
--- a/src/Ubiquity.NET.CommandLine/DiagnosticMessage.cs
+++ b/src/Ubiquity.NET.CommandLine/DiagnosticMessage.cs
@@ -1,13 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System;
-using System.Diagnostics.CodeAnalysis;
-using System.Globalization;
-using System.Linq;
-
-using Ubiquity.NET.Extensions;
-
namespace Ubiquity.NET.CommandLine
{
/// Tool Message category
diff --git a/src/Ubiquity.NET.CommandLine/DiagnosticMessageCollection.cs b/src/Ubiquity.NET.CommandLine/DiagnosticMessageCollection.cs
index 6de2b4e4f..263048320 100644
--- a/src/Ubiquity.NET.CommandLine/DiagnosticMessageCollection.cs
+++ b/src/Ubiquity.NET.CommandLine/DiagnosticMessageCollection.cs
@@ -1,11 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System.Collections;
-using System.Collections.Generic;
-using System.Collections.Immutable;
-using System.Text;
-
namespace Ubiquity.NET.CommandLine
{
/// Reporter that collects diagnostic information without reporting it in any UI/UX
diff --git a/src/Ubiquity.NET.CommandLine/DiagnosticReporterExtensions.cs b/src/Ubiquity.NET.CommandLine/DiagnosticReporterExtensions.cs
index aacc777e9..3ae5eb52c 100644
--- a/src/Ubiquity.NET.CommandLine/DiagnosticReporterExtensions.cs
+++ b/src/Ubiquity.NET.CommandLine/DiagnosticReporterExtensions.cs
@@ -1,15 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System;
-using System.Collections.Generic;
-using System.Diagnostics.CodeAnalysis;
-using System.Globalization;
-using System.Runtime.CompilerServices;
-
-using Ubiquity.NET.CommandLine.InterpolatedStringHandlers;
-using Ubiquity.NET.Extensions;
-
namespace Ubiquity.NET.CommandLine
{
/// Extensions to for specific message levels
diff --git a/src/Ubiquity.NET.CommandLine/GlobalNamespaceImports.cs b/src/Ubiquity.NET.CommandLine/GlobalNamespaceImports.cs
new file mode 100644
index 000000000..6e1097b80
--- /dev/null
+++ b/src/Ubiquity.NET.CommandLine/GlobalNamespaceImports.cs
@@ -0,0 +1,35 @@
+// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
+// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
+
+/*
+NOTE:
+While the MsBuild `ImplicitUsings` property is banned from this repo, the C# language feature of global usings is NOT.
+The build property will auto include an invisible and undiscoverable (without looking up obscure documentation)
+set of namespaces that is NOT consistent or controlled by the developer. THAT is what is BAD/BROKEN about that feature.
+By banning it's use and then providing a `GlobalNamespaceImports.cs` source file with ONLY global using statements ALL of
+that is eliminated. Such use of the language feature restores FULL control and visibility of the namespaces to the developer,
+where it belongs. For a good explanation of this problem see: https://rehansaeed.com/the-problem-with-csharp-10-implicit-usings/.
+For an explanation of the benefits of the language feature see: https://www.hanselman.com/blog/implicit-usings-in-net-6
+*/
+
+global using System;
+global using System.Collections;
+global using System.Collections.Generic;
+global using System.Collections.Immutable;
+global using System.CommandLine;
+global using System.CommandLine.Completions;
+global using System.CommandLine.Help;
+global using System.CommandLine.Invocation;
+global using System.CommandLine.Parsing;
+global using System.ComponentModel;
+global using System.Diagnostics.CodeAnalysis;
+global using System.Globalization;
+global using System.IO;
+global using System.Linq;
+global using System.Runtime.CompilerServices;
+global using System.Text;
+
+global using AnsiCodes;
+
+global using Ubiquity.NET.CommandLine.InterpolatedStringHandlers;
+global using Ubiquity.NET.Extensions;
diff --git a/src/Ubiquity.NET.CommandLine/ICommandLineOptions.cs b/src/Ubiquity.NET.CommandLine/ICommandLineOptions.cs
index 25fb48472..97b290c46 100644
--- a/src/Ubiquity.NET.CommandLine/ICommandLineOptions.cs
+++ b/src/Ubiquity.NET.CommandLine/ICommandLineOptions.cs
@@ -1,8 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System.CommandLine;
-
namespace Ubiquity.NET.CommandLine
{
/// Interface for a root command in command line parsing
diff --git a/src/Ubiquity.NET.CommandLine/IDiagnosticReporter.cs b/src/Ubiquity.NET.CommandLine/IDiagnosticReporter.cs
index 2c8ea931d..c73dc56b7 100644
--- a/src/Ubiquity.NET.CommandLine/IDiagnosticReporter.cs
+++ b/src/Ubiquity.NET.CommandLine/IDiagnosticReporter.cs
@@ -1,8 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System.Text;
-
namespace Ubiquity.NET.CommandLine
{
/// Interface for UX message reporting
diff --git a/src/Ubiquity.NET.CommandLine/InterpolatedStringHandlers/DiagnosticReporterInterpolatedStringHandler.cs b/src/Ubiquity.NET.CommandLine/InterpolatedStringHandlers/DiagnosticReporterInterpolatedStringHandler.cs
index a09fe96a2..1789550b4 100644
--- a/src/Ubiquity.NET.CommandLine/InterpolatedStringHandlers/DiagnosticReporterInterpolatedStringHandler.cs
+++ b/src/Ubiquity.NET.CommandLine/InterpolatedStringHandlers/DiagnosticReporterInterpolatedStringHandler.cs
@@ -1,12 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System;
-using System.Diagnostics.CodeAnalysis;
-using System.Globalization;
-using System.Runtime.CompilerServices;
-using System.Text;
-
namespace Ubiquity.NET.CommandLine.InterpolatedStringHandlers
{
/// Interpolated string handler for an
diff --git a/src/Ubiquity.NET.CommandLine/InterpolatedStringHandlers/ErrorReportingInterpolatedStringHandler.cs b/src/Ubiquity.NET.CommandLine/InterpolatedStringHandlers/ErrorReportingInterpolatedStringHandler.cs
index b0f43e938..52ba40aa8 100644
--- a/src/Ubiquity.NET.CommandLine/InterpolatedStringHandlers/ErrorReportingInterpolatedStringHandler.cs
+++ b/src/Ubiquity.NET.CommandLine/InterpolatedStringHandlers/ErrorReportingInterpolatedStringHandler.cs
@@ -1,11 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System;
-using System.Diagnostics.CodeAnalysis;
-using System.Runtime.CompilerServices;
-using System.Text;
-
namespace Ubiquity.NET.CommandLine.InterpolatedStringHandlers
{
/// Interpolated string handler for an using a fixed
diff --git a/src/Ubiquity.NET.CommandLine/InterpolatedStringHandlers/InformationReportingInterpolatedStringHandler.cs b/src/Ubiquity.NET.CommandLine/InterpolatedStringHandlers/InformationReportingInterpolatedStringHandler.cs
index 5eb9bb4db..23ad5009c 100644
--- a/src/Ubiquity.NET.CommandLine/InterpolatedStringHandlers/InformationReportingInterpolatedStringHandler.cs
+++ b/src/Ubiquity.NET.CommandLine/InterpolatedStringHandlers/InformationReportingInterpolatedStringHandler.cs
@@ -1,11 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System;
-using System.Diagnostics.CodeAnalysis;
-using System.Runtime.CompilerServices;
-using System.Text;
-
namespace Ubiquity.NET.CommandLine.InterpolatedStringHandlers
{
/// Interpolated string handler for an using a fixed
diff --git a/src/Ubiquity.NET.CommandLine/InterpolatedStringHandlers/VerboseReportingInterpolatedStringHandler.cs b/src/Ubiquity.NET.CommandLine/InterpolatedStringHandlers/VerboseReportingInterpolatedStringHandler.cs
index 2b49cd0c2..0e5e06900 100644
--- a/src/Ubiquity.NET.CommandLine/InterpolatedStringHandlers/VerboseReportingInterpolatedStringHandler.cs
+++ b/src/Ubiquity.NET.CommandLine/InterpolatedStringHandlers/VerboseReportingInterpolatedStringHandler.cs
@@ -1,11 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System;
-using System.Diagnostics.CodeAnalysis;
-using System.Runtime.CompilerServices;
-using System.Text;
-
namespace Ubiquity.NET.CommandLine.InterpolatedStringHandlers
{
/// Interpolated string handler for an using a fixed
diff --git a/src/Ubiquity.NET.CommandLine/InterpolatedStringHandlers/WarningReportingInterpolatedStringHandler.cs b/src/Ubiquity.NET.CommandLine/InterpolatedStringHandlers/WarningReportingInterpolatedStringHandler.cs
index 799998424..6bfc64371 100644
--- a/src/Ubiquity.NET.CommandLine/InterpolatedStringHandlers/WarningReportingInterpolatedStringHandler.cs
+++ b/src/Ubiquity.NET.CommandLine/InterpolatedStringHandlers/WarningReportingInterpolatedStringHandler.cs
@@ -1,11 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System;
-using System.Diagnostics.CodeAnalysis;
-using System.Runtime.CompilerServices;
-using System.Text;
-
namespace Ubiquity.NET.CommandLine.InterpolatedStringHandlers
{
/// Interpolated string handler for an using a fixed
diff --git a/src/Ubiquity.NET.CommandLine/ParseResultExtensions.cs b/src/Ubiquity.NET.CommandLine/ParseResultExtensions.cs
index d97c2dfd4..bcac7428c 100644
--- a/src/Ubiquity.NET.CommandLine/ParseResultExtensions.cs
+++ b/src/Ubiquity.NET.CommandLine/ParseResultExtensions.cs
@@ -1,13 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System;
-using System.Collections.Generic;
-using System.CommandLine;
-using System.CommandLine.Help;
-using System.CommandLine.Parsing;
-using System.Linq;
-
namespace Ubiquity.NET.CommandLine
{
// This does NOT use the new C# 14 extension syntax due to several reasons
diff --git a/src/Ubiquity.NET.CommandLine/ReportingSettings.cs b/src/Ubiquity.NET.CommandLine/ReportingSettings.cs
index 51f19f18c..b6cc26e5f 100644
--- a/src/Ubiquity.NET.CommandLine/ReportingSettings.cs
+++ b/src/Ubiquity.NET.CommandLine/ReportingSettings.cs
@@ -1,12 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System;
-using System.CommandLine;
-using System.Diagnostics.CodeAnalysis;
-using System.IO;
-using System.Text;
-
namespace Ubiquity.NET.CommandLine
{
// internal extension for IDiagnosticReporter
diff --git a/src/Ubiquity.NET.CommandLine/SymbolValidationExtensions.cs b/src/Ubiquity.NET.CommandLine/SymbolValidationExtensions.cs
index 0e9324aa1..8154283b5 100644
--- a/src/Ubiquity.NET.CommandLine/SymbolValidationExtensions.cs
+++ b/src/Ubiquity.NET.CommandLine/SymbolValidationExtensions.cs
@@ -1,13 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System;
-using System.Collections.Generic;
-using System.CommandLine;
-using System.CommandLine.Parsing;
-using System.IO;
-using System.Runtime.CompilerServices;
-
namespace Ubiquity.NET.CommandLine
{
/// Utility class to provide extensions for validation of options and arguments
diff --git a/src/Ubiquity.NET.CommandLine/TextWriterReporter.cs b/src/Ubiquity.NET.CommandLine/TextWriterReporter.cs
index e09c60989..faed113c3 100644
--- a/src/Ubiquity.NET.CommandLine/TextWriterReporter.cs
+++ b/src/Ubiquity.NET.CommandLine/TextWriterReporter.cs
@@ -1,12 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System;
-using System.ComponentModel;
-using System.Diagnostics.CodeAnalysis;
-using System.IO;
-using System.Text;
-
namespace Ubiquity.NET.CommandLine
{
/// Base class for reporting diagnostics via an instance of
diff --git a/src/Ubiquity.NET.Extensions/AssemblyExtensions.cs b/src/Ubiquity.NET.Extensions/AssemblyExtensions.cs
index b044128a5..fde6e1e3a 100644
--- a/src/Ubiquity.NET.Extensions/AssemblyExtensions.cs
+++ b/src/Ubiquity.NET.Extensions/AssemblyExtensions.cs
@@ -1,10 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System;
-using System.Reflection;
-using System.Runtime.CompilerServices;
-
namespace Ubiquity.NET.Extensions
{
// This does NOT use the new C# 14 extension syntax due to several reasons
diff --git a/src/Ubiquity.NET.Extensions/DictionaryBuilder.cs b/src/Ubiquity.NET.Extensions/DictionaryBuilder.cs
index 83e562db9..9ade8101b 100644
--- a/src/Ubiquity.NET.Extensions/DictionaryBuilder.cs
+++ b/src/Ubiquity.NET.Extensions/DictionaryBuilder.cs
@@ -1,11 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System;
-using System.Collections;
-using System.Collections.Immutable;
-using System.Diagnostics.CodeAnalysis;
-
namespace Ubiquity.NET.Extensions
{
/// Simple type to support direct creation of an immutable array via
diff --git a/src/Ubiquity.NET.Extensions/DisposableAction.cs b/src/Ubiquity.NET.Extensions/DisposableAction.cs
index 13ef46ca2..8938c5d58 100644
--- a/src/Ubiquity.NET.Extensions/DisposableAction.cs
+++ b/src/Ubiquity.NET.Extensions/DisposableAction.cs
@@ -1,10 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System;
-using System.Runtime.CompilerServices;
-using System.Threading;
-
namespace Ubiquity.NET.Extensions
{
/// Disposable type that runs a specified action on dispose
diff --git a/src/Ubiquity.NET.Extensions/FluentValidationExtensions.cs b/src/Ubiquity.NET.Extensions/FluentValidationExtensions.cs
index 1dec4529f..8352cd8b1 100644
--- a/src/Ubiquity.NET.Extensions/FluentValidationExtensions.cs
+++ b/src/Ubiquity.NET.Extensions/FluentValidationExtensions.cs
@@ -1,13 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System;
-using System.ComponentModel;
-using System.Diagnostics;
-using System.Diagnostics.CodeAnalysis;
-using System.Globalization;
-using System.Runtime.CompilerServices;
-
namespace Ubiquity.NET.Extensions
{
// This does NOT use the new C# 14 extension syntax due to several reasons
diff --git a/src/Ubiquity.NET.Extensions/GlobalNamespaceImports.cs b/src/Ubiquity.NET.Extensions/GlobalNamespaceImports.cs
new file mode 100644
index 000000000..6302a74f7
--- /dev/null
+++ b/src/Ubiquity.NET.Extensions/GlobalNamespaceImports.cs
@@ -0,0 +1,26 @@
+// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
+// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
+
+/*
+NOTE:
+While the MsBuild `ImplicitUsings` property is banned from this repo, the C# language feature of global usings is NOT.
+The build property will auto include an invisible and undiscoverable (without looking up obscure documentation)
+set of namespaces that is NOT consistent or controlled by the developer. THAT is what is BAD/BROKEN about that feature.
+By banning it's use and then providing a `GlobalNamespaceImports.cs` source file with ONLY global using statements ALL of
+that is eliminated. Such use of the language feature restores FULL control and visibility of the namespaces to the developer,
+where it belongs. For a good explanation of this problem see: https://rehansaeed.com/the-problem-with-csharp-10-implicit-usings/.
+For an explanation of the benefits of the language feature see: https://www.hanselman.com/blog/implicit-usings-in-net-6
+*/
+
+global using System;
+global using System.Collections;
+global using System.Collections.Generic;
+global using System.Collections.Immutable;
+global using System.ComponentModel;
+global using System.Diagnostics;
+global using System.Diagnostics.CodeAnalysis;
+global using System.Globalization;
+global using System.IO;
+global using System.Reflection;
+global using System.Runtime.CompilerServices;
+global using System.Threading;
diff --git a/src/Ubiquity.NET.Extensions/KvpArrayBuilder.cs b/src/Ubiquity.NET.Extensions/KvpArrayBuilder.cs
index a2902f8cc..b533adb04 100644
--- a/src/Ubiquity.NET.Extensions/KvpArrayBuilder.cs
+++ b/src/Ubiquity.NET.Extensions/KvpArrayBuilder.cs
@@ -1,12 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Collections.Immutable;
-using System.Diagnostics.CodeAnalysis;
-
namespace Ubiquity.NET.Extensions
{
/// Simple type to support dictionary style creation of an immutable array of KeyValue pairs via
diff --git a/src/Ubiquity.NET.Extensions/MustUseReturnValueAttribute.cs b/src/Ubiquity.NET.Extensions/MustUseReturnValueAttribute.cs
index 8fb2b87c4..43447d89f 100644
--- a/src/Ubiquity.NET.Extensions/MustUseReturnValueAttribute.cs
+++ b/src/Ubiquity.NET.Extensions/MustUseReturnValueAttribute.cs
@@ -1,8 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System;
-
namespace Ubiquity.NET.Extensions
{
/// `MustUseRetVal` analyzer compatible attribute
diff --git a/src/Ubiquity.NET.Extensions/ProcessInfo.cs b/src/Ubiquity.NET.Extensions/ProcessInfo.cs
index 7f61b1391..55ba51ef8 100644
--- a/src/Ubiquity.NET.Extensions/ProcessInfo.cs
+++ b/src/Ubiquity.NET.Extensions/ProcessInfo.cs
@@ -1,10 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System;
-using System.IO;
-using System.Reflection;
-
namespace Ubiquity.NET.Extensions
{
/// Process related extensions/support
diff --git a/src/Ubiquity.NET.Extensions/SourcePosition.cs b/src/Ubiquity.NET.Extensions/SourcePosition.cs
index ab48f81cc..0f0e0bcbc 100644
--- a/src/Ubiquity.NET.Extensions/SourcePosition.cs
+++ b/src/Ubiquity.NET.Extensions/SourcePosition.cs
@@ -1,11 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System;
-using System.ComponentModel;
-using System.Diagnostics;
-using System.Diagnostics.CodeAnalysis;
-
namespace Ubiquity.NET.Extensions
{
/// Represents a single point position in a source input
diff --git a/src/Ubiquity.NET.Extensions/SourceRange.cs b/src/Ubiquity.NET.Extensions/SourceRange.cs
index ab9b839c2..82f48aaae 100644
--- a/src/Ubiquity.NET.Extensions/SourceRange.cs
+++ b/src/Ubiquity.NET.Extensions/SourceRange.cs
@@ -1,10 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System;
-using System.Diagnostics.CodeAnalysis;
-using System.Globalization;
-
namespace Ubiquity.NET.Extensions
{
/// Abstraction to hold a source location range as a pair of values
diff --git a/src/Ubiquity.NET.Extensions/StringNormalizer.cs b/src/Ubiquity.NET.Extensions/StringNormalizer.cs
index ed99cceb2..cb69cddb2 100644
--- a/src/Ubiquity.NET.Extensions/StringNormalizer.cs
+++ b/src/Ubiquity.NET.Extensions/StringNormalizer.cs
@@ -1,10 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System;
-using System.ComponentModel;
-using System.Diagnostics.CodeAnalysis;
-
namespace Ubiquity.NET.Extensions
{
/// The kind of line endings for a string of characters
diff --git a/src/Ubiquity.NET.InteropHelpers/CStringHandle.cs b/src/Ubiquity.NET.InteropHelpers/CStringHandle.cs
index 46a973906..1f4847359 100644
--- a/src/Ubiquity.NET.InteropHelpers/CStringHandle.cs
+++ b/src/Ubiquity.NET.InteropHelpers/CStringHandle.cs
@@ -1,11 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System;
-using System.Diagnostics.CodeAnalysis;
-using System.Runtime.InteropServices;
-using System.Threading;
-
namespace Ubiquity.NET.InteropHelpers
{
/// Abstract base class for types that represents a native string
diff --git a/src/Ubiquity.NET.InteropHelpers/EncodingExtensions.cs b/src/Ubiquity.NET.InteropHelpers/EncodingExtensions.cs
index 9aa79696d..fa359fb15 100644
--- a/src/Ubiquity.NET.InteropHelpers/EncodingExtensions.cs
+++ b/src/Ubiquity.NET.InteropHelpers/EncodingExtensions.cs
@@ -1,10 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System;
-using System.Runtime.InteropServices;
-using System.Text;
-
namespace Ubiquity.NET.InteropHelpers
{
/// Utility extensions for the class
diff --git a/src/Ubiquity.NET.InteropHelpers/ExecutionEncodingStringMarshaller.cs b/src/Ubiquity.NET.InteropHelpers/ExecutionEncodingStringMarshaller.cs
index bd7d0c94e..abe99e8b9 100644
--- a/src/Ubiquity.NET.InteropHelpers/ExecutionEncodingStringMarshaller.cs
+++ b/src/Ubiquity.NET.InteropHelpers/ExecutionEncodingStringMarshaller.cs
@@ -1,14 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System;
-using System.Diagnostics;
-using System.Diagnostics.CodeAnalysis;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-using System.Runtime.InteropServices.Marshalling;
-using System.Text;
-
namespace Ubiquity.NET.InteropHelpers
{
/// Represents a marshaller for native strings using .
diff --git a/src/Ubiquity.NET.InteropHelpers/GlobalNamespaceImports.cs b/src/Ubiquity.NET.InteropHelpers/GlobalNamespaceImports.cs
new file mode 100644
index 000000000..73aea4bd9
--- /dev/null
+++ b/src/Ubiquity.NET.InteropHelpers/GlobalNamespaceImports.cs
@@ -0,0 +1,29 @@
+// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
+// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
+
+/*
+NOTE:
+While the MsBuild `ImplicitUsings` property is banned from this repo, the C# language feature of global usings is NOT.
+The build property will auto include an invisible and undiscoverable (without looking up obscure documentation)
+set of namespaces that is NOT consistent or controlled by the developer. THAT is what is BAD/BROKEN about that feature.
+By banning it's use and then providing a `GlobalNamespaceImports.cs` source file with ONLY global using statements ALL of
+that is eliminated. Such use of the language feature restores FULL control and visibility of the namespaces to the developer,
+where it belongs. For a good explanation of this problem see: https://rehansaeed.com/the-problem-with-csharp-10-implicit-usings/.
+For an explanation of the benefits of the language feature see: https://www.hanselman.com/blog/implicit-usings-in-net-6
+*/
+
+global using System;
+global using System.Buffers;
+global using System.Collections.Generic;
+global using System.Diagnostics;
+global using System.Diagnostics.CodeAnalysis;
+global using System.Numerics;
+global using System.Reflection;
+global using System.Resources;
+global using System.Runtime.CompilerServices;
+global using System.Runtime.InteropServices;
+global using System.Runtime.InteropServices.Marshalling;
+global using System.Text;
+global using System.Threading;
+
+global using Ubiquity.NET.Extensions;
diff --git a/src/Ubiquity.NET.InteropHelpers/LazyEncodedString.cs b/src/Ubiquity.NET.InteropHelpers/LazyEncodedString.cs
index dead0900d..ce6bce0df 100644
--- a/src/Ubiquity.NET.InteropHelpers/LazyEncodedString.cs
+++ b/src/Ubiquity.NET.InteropHelpers/LazyEncodedString.cs
@@ -1,18 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System;
-using System.Buffers;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Diagnostics.CodeAnalysis;
-using System.Numerics;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-using System.Runtime.InteropServices.Marshalling;
-using System.Text;
-using System.Threading;
-
namespace Ubiquity.NET.InteropHelpers
{
/// Lazily encoded string with implicit casting to a read only span of bytes or a normal managed string
diff --git a/src/Ubiquity.NET.InteropHelpers/LazyEncodedStringMarshaller.cs b/src/Ubiquity.NET.InteropHelpers/LazyEncodedStringMarshaller.cs
index 3c2ace0aa..fdf77c00c 100644
--- a/src/Ubiquity.NET.InteropHelpers/LazyEncodedStringMarshaller.cs
+++ b/src/Ubiquity.NET.InteropHelpers/LazyEncodedStringMarshaller.cs
@@ -1,11 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System;
-using System.Buffers;
-using System.Diagnostics.CodeAnalysis;
-using System.Runtime.InteropServices.Marshalling;
-
namespace Ubiquity.NET.InteropHelpers
{
/// Represents a marshaller for .
diff --git a/src/Ubiquity.NET.InteropHelpers/NativeContext.cs b/src/Ubiquity.NET.InteropHelpers/NativeContext.cs
index 9fddaeb51..3a42e6a5f 100644
--- a/src/Ubiquity.NET.InteropHelpers/NativeContext.cs
+++ b/src/Ubiquity.NET.InteropHelpers/NativeContext.cs
@@ -1,12 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System.Diagnostics;
-using System.Diagnostics.CodeAnalysis;
-using System.Runtime.InteropServices;
-
-using Ubiquity.NET.Extensions;
-
namespace Ubiquity.NET.InteropHelpers
{
// This does NOT use the new C# 14 extension syntax due to several reasons
diff --git a/src/Ubiquity.NET.InteropHelpers/NativeLibraryHandle.cs b/src/Ubiquity.NET.InteropHelpers/NativeLibraryHandle.cs
index 3525fed57..6d0ac302c 100644
--- a/src/Ubiquity.NET.InteropHelpers/NativeLibraryHandle.cs
+++ b/src/Ubiquity.NET.InteropHelpers/NativeLibraryHandle.cs
@@ -1,10 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System.Diagnostics.CodeAnalysis;
-using System.Reflection;
-using System.Runtime.InteropServices;
-
namespace Ubiquity.NET.InteropHelpers
{
/// Safe handle for a
diff --git a/src/Ubiquity.NET.InteropHelpers/Properties/AssemblyInfo.cs b/src/Ubiquity.NET.InteropHelpers/Properties/AssemblyInfo.cs
index 3709b17f0..eb5aba066 100644
--- a/src/Ubiquity.NET.InteropHelpers/Properties/AssemblyInfo.cs
+++ b/src/Ubiquity.NET.InteropHelpers/Properties/AssemblyInfo.cs
@@ -1,10 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System;
-using System.Resources;
-using System.Runtime.InteropServices;
-
// In SDK-style projects such as this one, several assembly attributes that were historically
// defined in this file are now automatically added during build and populated with
// values defined in project properties. For details of which attributes are included
diff --git a/src/Ubiquity.NET.InteropHelpers/RefHandleMarshaller.cs b/src/Ubiquity.NET.InteropHelpers/RefHandleMarshaller.cs
index b954ffaf5..904c42465 100644
--- a/src/Ubiquity.NET.InteropHelpers/RefHandleMarshaller.cs
+++ b/src/Ubiquity.NET.InteropHelpers/RefHandleMarshaller.cs
@@ -1,11 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System;
-using System.Buffers;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
namespace Ubiquity.NET.InteropHelpers
{
/// Performs custom marshalling of handle arrays as in parameters
diff --git a/src/Ubiquity.NET.InteropHelpers/UnexpectedNullHandleException.cs b/src/Ubiquity.NET.InteropHelpers/UnexpectedNullHandleException.cs
index a511ec41b..71a3518a2 100644
--- a/src/Ubiquity.NET.InteropHelpers/UnexpectedNullHandleException.cs
+++ b/src/Ubiquity.NET.InteropHelpers/UnexpectedNullHandleException.cs
@@ -1,8 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System;
-
namespace Ubiquity.NET.InteropHelpers
{
/// Exception thrown when an underlying Native API `handle` is unexpectedly
diff --git a/src/Ubiquity.NET.Llvm/Blake3Hash.cs b/src/Ubiquity.NET.Llvm/Blake3Hash.cs
index 8ae331cab..eadfa541d 100644
--- a/src/Ubiquity.NET.Llvm/Blake3Hash.cs
+++ b/src/Ubiquity.NET.Llvm/Blake3Hash.cs
@@ -1,8 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System.Security.Cryptography;
-
using static Ubiquity.NET.Llvm.Interop.ABI.llvm_c.Blake3;
namespace Ubiquity.NET.Llvm
diff --git a/src/Ubiquity.NET.Llvm/GlobalNamespaceImports.cs b/src/Ubiquity.NET.Llvm/GlobalNamespaceImports.cs
index ff5ec5c6a..e57085846 100644
--- a/src/Ubiquity.NET.Llvm/GlobalNamespaceImports.cs
+++ b/src/Ubiquity.NET.Llvm/GlobalNamespaceImports.cs
@@ -29,6 +29,7 @@ where it belongs.
global using System.Linq;
global using System.Runtime.CompilerServices;
global using System.Runtime.InteropServices;
+global using System.Security.Cryptography;
global using System.Text;
global using System.Threading;
diff --git a/src/Ubiquity.NET.Llvm/OrcJITv2/MaterializationUnit.cs b/src/Ubiquity.NET.Llvm/OrcJITv2/MaterializationUnit.cs
index aa1afadac..c82d011ca 100644
--- a/src/Ubiquity.NET.Llvm/OrcJITv2/MaterializationUnit.cs
+++ b/src/Ubiquity.NET.Llvm/OrcJITv2/MaterializationUnit.cs
@@ -4,8 +4,6 @@
// Elements ARE ordered correctly, analyzer has dumb defaults and doesn't allow override of order
#pragma warning disable SA1202 // Elements should be ordered by access
-using static Ubiquity.NET.Llvm.Interop.ABI.llvm_c.Orc;
-
namespace Ubiquity.NET.Llvm.OrcJITv2
{
/// Abstract base class for an LLVM ORC JIT v2 Materialization Unit
diff --git a/src/Ubiquity.NET.Runtime.Utils/AnonymousNameProvider.cs b/src/Ubiquity.NET.Runtime.Utils/AnonymousNameProvider.cs
index 96d5ce412..fa9989e58 100644
--- a/src/Ubiquity.NET.Runtime.Utils/AnonymousNameProvider.cs
+++ b/src/Ubiquity.NET.Runtime.Utils/AnonymousNameProvider.cs
@@ -1,11 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Diagnostics.CodeAnalysis;
-
namespace Ubiquity.NET.Runtime.Utils
{
/// Provides anonymous names as a sequence of strings with an enumerated integral suffix
diff --git a/src/Ubiquity.NET.Runtime.Utils/AstNode.cs b/src/Ubiquity.NET.Runtime.Utils/AstNode.cs
index 810f744da..5775fe79b 100644
--- a/src/Ubiquity.NET.Runtime.Utils/AstNode.cs
+++ b/src/Ubiquity.NET.Runtime.Utils/AstNode.cs
@@ -1,10 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System.Collections.Generic;
-
-using Ubiquity.NET.Extensions;
-
namespace Ubiquity.NET.Runtime.Utils
{
/// Common abstract base implementation of
diff --git a/src/Ubiquity.NET.Runtime.Utils/AstNodeExtensions.cs b/src/Ubiquity.NET.Runtime.Utils/AstNodeExtensions.cs
index a612a2383..692f9552c 100644
--- a/src/Ubiquity.NET.Runtime.Utils/AstNodeExtensions.cs
+++ b/src/Ubiquity.NET.Runtime.Utils/AstNodeExtensions.cs
@@ -1,9 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System;
-using System.Collections.Immutable;
-
namespace Ubiquity.NET.Runtime.Utils
{
/// Extensions for IAstNode
diff --git a/src/Ubiquity.NET.Runtime.Utils/AstVisitorBase.cs b/src/Ubiquity.NET.Runtime.Utils/AstVisitorBase.cs
index 04421bd3c..e9b8637f0 100644
--- a/src/Ubiquity.NET.Runtime.Utils/AstVisitorBase.cs
+++ b/src/Ubiquity.NET.Runtime.Utils/AstVisitorBase.cs
@@ -1,9 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System;
-using System.Diagnostics.CodeAnalysis;
-
namespace Ubiquity.NET.Runtime.Utils
{
///
diff --git a/src/Ubiquity.NET.Runtime.Utils/CodeGeneratorException.cs b/src/Ubiquity.NET.Runtime.Utils/CodeGeneratorException.cs
index 8fb514bd2..3ef654e6d 100644
--- a/src/Ubiquity.NET.Runtime.Utils/CodeGeneratorException.cs
+++ b/src/Ubiquity.NET.Runtime.Utils/CodeGeneratorException.cs
@@ -1,8 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System;
-
namespace Ubiquity.NET.Runtime.Utils
{
/// Exception to represent an error in the code generation of a DSL
diff --git a/src/Ubiquity.NET.Runtime.Utils/ErrorNode.cs b/src/Ubiquity.NET.Runtime.Utils/ErrorNode.cs
index cf8756ce7..112da586b 100644
--- a/src/Ubiquity.NET.Runtime.Utils/ErrorNode.cs
+++ b/src/Ubiquity.NET.Runtime.Utils/ErrorNode.cs
@@ -1,11 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System;
-using System.Collections.Generic;
-using Ubiquity.NET.CommandLine;
-using Ubiquity.NET.Extensions;
-
namespace Ubiquity.NET.Runtime.Utils
{
/// Represents an IAstNode where an error occurred in the parse
diff --git a/src/Ubiquity.NET.Runtime.Utils/ErrorNodeCollector.cs b/src/Ubiquity.NET.Runtime.Utils/ErrorNodeCollector.cs
index 5cec9604b..508cd9316 100644
--- a/src/Ubiquity.NET.Runtime.Utils/ErrorNodeCollector.cs
+++ b/src/Ubiquity.NET.Runtime.Utils/ErrorNodeCollector.cs
@@ -1,8 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System.Collections.Immutable;
-
namespace Ubiquity.NET.Runtime.Utils
{
/// AST visitor that collects all errors for a given node
diff --git a/src/Ubiquity.NET.Runtime.Utils/GlobalNamespaceImports.cs b/src/Ubiquity.NET.Runtime.Utils/GlobalNamespaceImports.cs
new file mode 100644
index 000000000..b990188c1
--- /dev/null
+++ b/src/Ubiquity.NET.Runtime.Utils/GlobalNamespaceImports.cs
@@ -0,0 +1,33 @@
+// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
+// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
+
+/*
+NOTE:
+While the MsBuild `ImplicitUsings` property is banned from this repo, the C# language feature of global usings is NOT.
+The build property will auto include an invisible and undiscoverable (without looking up obscure documentation)
+set of namespaces that is NOT consistent or controlled by the developer. THAT is what is BAD/BROKEN about that feature.
+By banning it's use and then providing a `GlobalNamespaceImports.cs` source file with ONLY global using statements ALL of
+that is eliminated. Such use of the language feature restores FULL control and visibility of the namespaces to the developer,
+where it belongs. For a good explanation of this problem see: https://rehansaeed.com/the-problem-with-csharp-10-implicit-usings/.
+For an explanation of the benefits of the language feature see: https://www.hanselman.com/blog/implicit-usings-in-net-6
+*/
+
+global using System;
+global using System.CodeDom.Compiler;
+global using System.Collections;
+global using System.Collections.Generic;
+global using System.Collections.Immutable;
+global using System.Diagnostics.CodeAnalysis;
+global using System.Globalization;
+global using System.IO;
+global using System.Linq;
+global using System.Runtime.CompilerServices;
+global using System.Text;
+global using System.Threading;
+global using System.Threading.Tasks;
+global using System.Xml.Linq;
+
+global using Ubiquity.NET.CommandLine;
+global using Ubiquity.NET.Extensions;
+global using Ubiquity.NET.InteropHelpers;
+global using Ubiquity.NET.SrcGeneration.CSharp;
diff --git a/src/Ubiquity.NET.Runtime.Utils/IAstNode.cs b/src/Ubiquity.NET.Runtime.Utils/IAstNode.cs
index 929344a44..d3c293365 100644
--- a/src/Ubiquity.NET.Runtime.Utils/IAstNode.cs
+++ b/src/Ubiquity.NET.Runtime.Utils/IAstNode.cs
@@ -1,10 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System.Collections.Generic;
-
-using Ubiquity.NET.Extensions;
-
namespace Ubiquity.NET.Runtime.Utils
{
/// Root interface for nodes in the Abstract Syntax Tree
diff --git a/src/Ubiquity.NET.Runtime.Utils/ICodeGenerator.cs b/src/Ubiquity.NET.Runtime.Utils/ICodeGenerator.cs
index 08590e535..2a84727d1 100644
--- a/src/Ubiquity.NET.Runtime.Utils/ICodeGenerator.cs
+++ b/src/Ubiquity.NET.Runtime.Utils/ICodeGenerator.cs
@@ -1,8 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System;
-
namespace Ubiquity.NET.Runtime.Utils
{
/// Interface for a Kaleidoscope code generator
diff --git a/src/Ubiquity.NET.Runtime.Utils/IParseErrorReporter.cs b/src/Ubiquity.NET.Runtime.Utils/IParseErrorReporter.cs
index fb26572a6..745114af7 100644
--- a/src/Ubiquity.NET.Runtime.Utils/IParseErrorReporter.cs
+++ b/src/Ubiquity.NET.Runtime.Utils/IParseErrorReporter.cs
@@ -1,9 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System;
-using System.Diagnostics.CodeAnalysis;
-
namespace Ubiquity.NET.Runtime.Utils
{
/// Interface for a logger of parse errors
diff --git a/src/Ubiquity.NET.Runtime.Utils/IParser.cs b/src/Ubiquity.NET.Runtime.Utils/IParser.cs
index 260bc1894..7c413396b 100644
--- a/src/Ubiquity.NET.Runtime.Utils/IParser.cs
+++ b/src/Ubiquity.NET.Runtime.Utils/IParser.cs
@@ -1,8 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System.IO;
-
// CONSIDER: Adaptation that accepts IParsesErrorReporter as a param argument to the parse APIs instead of relying on
// an implementation to "hold" one.
diff --git a/src/Ubiquity.NET.Runtime.Utils/IVisualizer.cs b/src/Ubiquity.NET.Runtime.Utils/IVisualizer.cs
index 9387bf169..4253116b6 100644
--- a/src/Ubiquity.NET.Runtime.Utils/IVisualizer.cs
+++ b/src/Ubiquity.NET.Runtime.Utils/IVisualizer.cs
@@ -1,8 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System.Xml.Linq;
-
namespace Ubiquity.NET.Runtime.Utils
{
/// Interface to process the results of a parse for "visualization"
diff --git a/src/Ubiquity.NET.Runtime.Utils/NullNode.cs b/src/Ubiquity.NET.Runtime.Utils/NullNode.cs
index 1505634ba..c4506448f 100644
--- a/src/Ubiquity.NET.Runtime.Utils/NullNode.cs
+++ b/src/Ubiquity.NET.Runtime.Utils/NullNode.cs
@@ -1,12 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System;
-using System.Collections.Generic;
-using System.Threading;
-
-using Ubiquity.NET.Extensions;
-
namespace Ubiquity.NET.Runtime.Utils
{
/// Null Object pattern implementation for AST Nodes
diff --git a/src/Ubiquity.NET.Runtime.Utils/ParseErrorCollector.cs b/src/Ubiquity.NET.Runtime.Utils/ParseErrorCollector.cs
index 709516e7b..f741a3edc 100644
--- a/src/Ubiquity.NET.Runtime.Utils/ParseErrorCollector.cs
+++ b/src/Ubiquity.NET.Runtime.Utils/ParseErrorCollector.cs
@@ -1,9 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System;
-using System.Collections.Immutable;
-
namespace Ubiquity.NET.Runtime.Utils
{
/// Implementation of to collect any errors that occur during a parse
diff --git a/src/Ubiquity.NET.Runtime.Utils/ParseErrorDiagnosticAdapter.cs b/src/Ubiquity.NET.Runtime.Utils/ParseErrorDiagnosticAdapter.cs
index 8334b49cd..ea151b802 100644
--- a/src/Ubiquity.NET.Runtime.Utils/ParseErrorDiagnosticAdapter.cs
+++ b/src/Ubiquity.NET.Runtime.Utils/ParseErrorDiagnosticAdapter.cs
@@ -1,11 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System;
-using System.Globalization;
-
-using Ubiquity.NET.CommandLine;
-
namespace Ubiquity.NET.Runtime.Utils
{
/// Adapter to redirect calls to to a given
diff --git a/src/Ubiquity.NET.Runtime.Utils/REPLBase.cs b/src/Ubiquity.NET.Runtime.Utils/REPLBase.cs
index 68d56323b..f1ede8847 100644
--- a/src/Ubiquity.NET.Runtime.Utils/REPLBase.cs
+++ b/src/Ubiquity.NET.Runtime.Utils/REPLBase.cs
@@ -1,11 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System.IO;
-using System.Linq;
-using System.Threading;
-using System.Threading.Tasks;
-
namespace Ubiquity.NET.Runtime.Utils
{
/// Common core implementation of a Read, Evaluate, Print Loop (REPL)
diff --git a/src/Ubiquity.NET.Runtime.Utils/ReadyStateManager.cs b/src/Ubiquity.NET.Runtime.Utils/ReadyStateManager.cs
index 7cbe12b1b..df3352965 100644
--- a/src/Ubiquity.NET.Runtime.Utils/ReadyStateManager.cs
+++ b/src/Ubiquity.NET.Runtime.Utils/ReadyStateManager.cs
@@ -1,8 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System;
-
namespace Ubiquity.NET.Runtime.Utils
{
/// Defines state for the UI for REPL parsing to show a prompt to the user
diff --git a/src/Ubiquity.NET.Runtime.Utils/ScopeStack.cs b/src/Ubiquity.NET.Runtime.Utils/ScopeStack.cs
index cfeed7c95..d77e133df 100644
--- a/src/Ubiquity.NET.Runtime.Utils/ScopeStack.cs
+++ b/src/Ubiquity.NET.Runtime.Utils/ScopeStack.cs
@@ -1,18 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System;
-using System.CodeDom.Compiler;
-using System.Collections.Generic;
-using System.Diagnostics.CodeAnalysis;
-using System.Globalization;
-using System.IO;
-using System.Text;
-
-using Ubiquity.NET.Extensions;
-using Ubiquity.NET.InteropHelpers;
-using Ubiquity.NET.SrcGeneration.CSharp;
-
namespace Ubiquity.NET.Runtime.Utils
{
/// Simple implementation of common Variable scoping
diff --git a/src/Ubiquity.NET.Runtime.Utils/SyntaxError.cs b/src/Ubiquity.NET.Runtime.Utils/SyntaxError.cs
index af661b5b1..79cac0eb6 100644
--- a/src/Ubiquity.NET.Runtime.Utils/SyntaxError.cs
+++ b/src/Ubiquity.NET.Runtime.Utils/SyntaxError.cs
@@ -1,10 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System;
-
-using Ubiquity.NET.Extensions;
-
namespace Ubiquity.NET.Runtime.Utils
{
/// Enumeration to indicate the source of an error during parse
diff --git a/src/Ubiquity.NET.Runtime.Utils/TextReaderExtensions.cs b/src/Ubiquity.NET.Runtime.Utils/TextReaderExtensions.cs
index 333b52fd7..6245b1a0c 100644
--- a/src/Ubiquity.NET.Runtime.Utils/TextReaderExtensions.cs
+++ b/src/Ubiquity.NET.Runtime.Utils/TextReaderExtensions.cs
@@ -1,13 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Runtime.CompilerServices;
-using System.Text;
-using System.Threading;
-
namespace Ubiquity.NET.Runtime.Utils
{
/// Utility class to provide extensions for REPL Loop and other scenarios requiring Async processing of text input
diff --git a/src/Ubiquity.NET.Runtime.Utils/Utilities.cs b/src/Ubiquity.NET.Runtime.Utils/Utilities.cs
index 4f3fd1f4d..68247d582 100644
--- a/src/Ubiquity.NET.Runtime.Utils/Utilities.cs
+++ b/src/Ubiquity.NET.Runtime.Utils/Utilities.cs
@@ -1,11 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System;
-using System.IO;
-using System.Linq;
-using System.Text;
-
namespace Ubiquity.NET.Runtime.Utils
{
/// Utility class to provide general functionality that would be "free standing" functions if allowed in the C# language
diff --git a/src/Ubiquity.NET.Runtime.Utils/VisualizationKind.cs b/src/Ubiquity.NET.Runtime.Utils/VisualizationKind.cs
index 7e211ae3c..3a0bee138 100644
--- a/src/Ubiquity.NET.Runtime.Utils/VisualizationKind.cs
+++ b/src/Ubiquity.NET.Runtime.Utils/VisualizationKind.cs
@@ -1,8 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System;
-
namespace Ubiquity.NET.Runtime.Utils
{
/// Enumeration to define the kinds of diagnostic intermediate data to generate from a runtime/language AST
diff --git a/src/Ubiquity.NET.SrcGeneration/CSharp/CSharpLanguage.cs b/src/Ubiquity.NET.SrcGeneration/CSharp/CSharpLanguage.cs
index 7db33dbf4..f4cf3ab0d 100644
--- a/src/Ubiquity.NET.SrcGeneration/CSharp/CSharpLanguage.cs
+++ b/src/Ubiquity.NET.SrcGeneration/CSharp/CSharpLanguage.cs
@@ -1,9 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System;
-using System.Collections.Immutable;
-
namespace Ubiquity.NET.SrcGeneration.CSharp
{
/// Support for generating source files in the C# language
@@ -104,9 +101,12 @@ public static string MakeIdentifier( this string self )
{
ArgumentNullException.ThrowIfNull( self );
+ // always replace invalid characters
+ // TODO: more sophisticated Regex that matches anything NOT a valid identifier char
+ string retVal = self.Replace( " ", "_", StringComparison.Ordinal );
return KeyWords.Contains( self )
- ? $"@{self}"
- : self.Replace( " ", "_", StringComparison.Ordinal );
+ ? $"@{retVal}"
+ : retVal;
}
}
}
diff --git a/src/Ubiquity.NET.SrcGeneration/CSharp/IndentedTextWriterCsExtensions.cs b/src/Ubiquity.NET.SrcGeneration/CSharp/IndentedTextWriterCsExtensions.cs
index a9189d190..f5868cc67 100644
--- a/src/Ubiquity.NET.SrcGeneration/CSharp/IndentedTextWriterCsExtensions.cs
+++ b/src/Ubiquity.NET.SrcGeneration/CSharp/IndentedTextWriterCsExtensions.cs
@@ -1,10 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System;
-using System.CodeDom.Compiler;
-using System.Diagnostics.CodeAnalysis;
-
namespace Ubiquity.NET.SrcGeneration.CSharp
{
/// Extensions to to support C# source generation
diff --git a/src/Ubiquity.NET.SrcGeneration/CSharp/TextWriterCsExtension.cs b/src/Ubiquity.NET.SrcGeneration/CSharp/TextWriterCsExtension.cs
index 53354640e..21d44e5a1 100644
--- a/src/Ubiquity.NET.SrcGeneration/CSharp/TextWriterCsExtension.cs
+++ b/src/Ubiquity.NET.SrcGeneration/CSharp/TextWriterCsExtension.cs
@@ -1,10 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System;
-using System.Diagnostics.CodeAnalysis;
-using System.IO;
-
namespace Ubiquity.NET.SrcGeneration.CSharp
{
/// Utility extensions for a specific to the C# language
diff --git a/src/Ubiquity.NET.SrcGeneration/GlobalNamespaceImports.cs b/src/Ubiquity.NET.SrcGeneration/GlobalNamespaceImports.cs
new file mode 100644
index 000000000..d9e3ac1fa
--- /dev/null
+++ b/src/Ubiquity.NET.SrcGeneration/GlobalNamespaceImports.cs
@@ -0,0 +1,24 @@
+// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
+// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
+
+/*
+NOTE:
+While the MsBuild `ImplicitUsings` property is banned from this repo, the C# language feature of global usings is NOT.
+The build property will auto include an invisible and undiscoverable (without looking up obscure documentation)
+set of namespaces that is NOT consistent or controlled by the developer. THAT is what is BAD/BROKEN about that feature.
+By banning it's use and then providing a `GlobalNamespaceImports.cs` source file with ONLY global using statements ALL of
+that is eliminated. Such use of the language feature restores FULL control and visibility of the namespaces to the developer,
+where it belongs. For a good explanation of this problem see: https://rehansaeed.com/the-problem-with-csharp-10-implicit-usings/.
+For an explanation of the benefits of the language feature see: https://www.hanselman.com/blog/implicit-usings-in-net-6
+*/
+
+global using System;
+global using System.CodeDom.Compiler;
+global using System.Collections.Generic;
+global using System.Collections.Immutable;
+global using System.Diagnostics.CodeAnalysis;
+global using System.IO;
+global using System.Linq;
+global using System.Xml.Linq;
+
+global using Ubiquity.NET.Extensions;
diff --git a/src/Ubiquity.NET.SrcGeneration/IndentedTextWriterExtensions.cs b/src/Ubiquity.NET.SrcGeneration/IndentedTextWriterExtensions.cs
index c3f23b11a..4968460f5 100644
--- a/src/Ubiquity.NET.SrcGeneration/IndentedTextWriterExtensions.cs
+++ b/src/Ubiquity.NET.SrcGeneration/IndentedTextWriterExtensions.cs
@@ -1,12 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System;
-using System.CodeDom.Compiler;
-using System.Diagnostics.CodeAnalysis;
-
-using Ubiquity.NET.Extensions;
-
namespace Ubiquity.NET.SrcGeneration
{
/// Extensions to to support C# source generation
diff --git a/src/Ubiquity.NET.SrcGeneration/ReadMe.md b/src/Ubiquity.NET.SrcGeneration/ReadMe.md
index 133bd78f7..91de33071 100644
--- a/src/Ubiquity.NET.SrcGeneration/ReadMe.md
+++ b/src/Ubiquity.NET.SrcGeneration/ReadMe.md
@@ -68,7 +68,7 @@ While other languages are possible this is the only one currently "built-in".
* `TextWriterCsExtension` to provide more extensions to a `TextWriter` that are specific to
the C# language.
* Method to write an attribute line
- * Method to write (without new line) and attribute
+ * Method to write (without new line) an attribute
* Method to write an XML Doc comment `summary` tag.
* Method to write an XML Doc comment `remarks` tag.
* Method to write an XML Doc comment `summary` and `remarks` tags with optional default
diff --git a/src/Ubiquity.NET.SrcGeneration/StringExtensions.cs b/src/Ubiquity.NET.SrcGeneration/StringExtensions.cs
index aecf6927d..ce20dde25 100644
--- a/src/Ubiquity.NET.SrcGeneration/StringExtensions.cs
+++ b/src/Ubiquity.NET.SrcGeneration/StringExtensions.cs
@@ -1,14 +1,6 @@
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
-using System;
-using System.Collections.Generic;
-using System.Diagnostics.CodeAnalysis;
-using System.Linq;
-using System.Xml.Linq;
-
-using Ubiquity.NET.Extensions;
-
namespace Ubiquity.NET.SrcGeneration
{
// TODO: What version of the language?