Skip to content

Commit

Permalink
feat(output) add using to output for libs
Browse files Browse the repository at this point in the history
  • Loading branch information
7schmiede committed May 17, 2022
1 parent 23759a9 commit ba60640
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/Generator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ public SourceText GetInputTextForStoredProcedure(Definition.Schema schema, Defin
var nsNode = (NamespaceDeclarationSyntax)root.Members[0];
var classNode = (ClassDeclarationSyntax)nsNode.Members[0];


// Create obsolete constructor
var obsoleteContructor = classNode.CreateConstructor($"{storedProcedure.Name}Input");
root = root.AddObsoleteAttribute(ref obsoleteContructor, "This empty contructor will be removed in vNext. Please use constructor with parameters.");
Expand Down Expand Up @@ -240,6 +239,13 @@ public SourceText GetOutputTextForStoredProcedure(Definition.Schema schema, Defi
var tree = CSharpSyntaxTree.ParseText(fileContent);
var root = tree.GetCompilationUnitRoot();

// Add Usings
if (_configFile.Config.Project.Role.Kind == ERoleKind.Lib)
{
var outputUsingDirective = SyntaxFactory.UsingDirective(SyntaxFactory.ParseName($"{_configFile.Config.Project.Output.Namespace}.Outputs"));
root = root.AddUsings(outputUsingDirective.NormalizeWhitespace().WithLeadingTrivia(SyntaxFactory.CarriageReturnLineFeed)).WithTrailingTrivia(SyntaxFactory.CarriageReturnLineFeed);
}

// Replace Namespace
if (_configFile.Config.Project.Role.Kind == ERoleKind.Lib)
{
Expand Down
2 changes: 1 addition & 1 deletion src/SpocR.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup Label="Build">
<Version>3.0.2</Version>
<Version>3.0.3</Version>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>

Expand Down

0 comments on commit ba60640

Please sign in to comment.