Skip to content

Commit

Permalink
Use global using and add implicit global usings
Browse files Browse the repository at this point in the history
  • Loading branch information
Sajidur78 committed Nov 25, 2023
1 parent f433153 commit 5b960f2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
5 changes: 2 additions & 3 deletions Source/Libraries/HedgeModManager.CodeCompiler/CSharpCode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ public CompilationUnitSyntax CreateCompilationUnit(IIncludeResolver? includeReso
// No processing for naked codes
if (Naked)
{
unit = AddImports(unit.AddUsings(CodeProvider.PredefinedUsingDirectives));
unit = AddImports(unit);

return unit;
}
Expand Down Expand Up @@ -400,8 +400,7 @@ public CompilationUnitSyntax CreateCompilationUnit(IIncludeResolver? includeReso

var compileUnit = SyntaxFactory.CompilationUnit()
.AddMembers(MakeRootMember())
.WithUsings(unit.Usings)
.AddUsings(CodeProvider.PredefinedUsingDirectives);
.WithUsings(unit.Usings);

compileUnit = AddImports(compileUnit);
return compileUnit;
Expand Down
10 changes: 0 additions & 10 deletions Source/Libraries/HedgeModManager.CodeCompiler/CodeProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,6 @@ public class CodeProvider
SyntaxFactory.MethodDeclaration(SyntaxFactory.PredefinedType(SyntaxFactory.Token(SyntaxKind.BoolKeyword)), "IsLoaderExecutable")
.WithExpressionBody(SyntaxFactory.ArrowExpressionClause(SyntaxFactory.LiteralExpression(SyntaxKind.TrueLiteralExpression)))
.WithModifiers(SyntaxFactory.TokenList(SyntaxFactory.Token(SyntaxKind.PublicKeyword), SyntaxFactory.Token(SyntaxKind.StaticKeyword)));

public static UsingDirectiveSyntax[] PredefinedUsingDirectives =
{
SyntaxFactory.UsingDirective(SyntaxFactory.IdentifierName("System")),
SyntaxFactory.UsingDirective(SyntaxFactory.IdentifierName("HMMCodes")),
SyntaxFactory.UsingDirective(
SyntaxFactory.Token(SyntaxKind.UsingKeyword),
SyntaxFactory.Token(SyntaxKind.StaticKeyword), null,
SyntaxFactory.QualifiedName(SyntaxFactory.IdentifierName("HMMCodes"), SyntaxFactory.IdentifierName("MemoryService")), SyntaxFactory.Token(SyntaxKind.SemicolonToken)),
};

public static SyntaxTree[] PredefinedClasses =
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
#pragma warning disable

global using global::System;
global using global::System.Collections.Generic;
global using global::System.IO;
global using global::System.Linq;
global using global::System.Threading;
global using global::System.Threading.Tasks;
global using global::HMMCodes;
global using static global::HMMCodes.MemoryService;

using System;
using System.Collections.Generic;
using System.Linq;
Expand Down

0 comments on commit 5b960f2

Please sign in to comment.