Skip to content

Commit

Permalink
Added StrawberryShake Code Generator Server (ChilliCream#4742)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelstaib authored Feb 10, 2022
1 parent 4e5aa62 commit e34f6ee
Show file tree
Hide file tree
Showing 105 changed files with 2,849 additions and 3,065 deletions.
51 changes: 0 additions & 51 deletions .build/Build.Publish.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,57 +77,6 @@ partial class Build
t => t.SetTargetPath(StarWarsTemplateNuSpec),
t => t.SetTargetPath(EmptyServerTemplateNuSpec),
t => t.SetTargetPath(TemplatesNuSpec)));

var analyzerProject = ProjectModelTasks
.ParseSolution(SgSolutionFile)
.GetProjects("*.Analyzers")
.Single();

Project parsedProject = ProjectModelTasks.ParseProject(analyzerProject);
ProjectItem packageReference = parsedProject.Items
.Single(t =>
t.ItemType == "PackageReference" &&
t.IsImported == false &&
t.EvaluatedInclude == "StrawberryShake.CodeGeneration.CSharp");
packageReference.SetMetadataValue("Version", GitVersion.SemVer);
parsedProject.Save();

DotNetBuild(c => c
.SetProjectFile(analyzerProject)
.SetConfiguration(Configuration)
.SetAssemblyVersion(GitVersion.AssemblySemVer)
.SetFileVersion(GitVersion.AssemblySemFileVer)
.SetInformationalVersion(GitVersion.InformationalVersion)
.SetVersion(GitVersion.SemVer));

DotNetPack(c => c
.SetProject(analyzerProject)
.SetNoBuild(InvokedTargets.Contains(Compile))
.SetConfiguration(Configuration)
.SetOutputDirectory(PackageDirectory)
.SetVersion(GitVersion.SemVer));

var analyzerTestProject = ProjectModelTasks
.ParseSolution(SgSolutionFile)
.GetProjects("*.Tests")
.Single();

parsedProject = ProjectModelTasks.ParseProject(analyzerTestProject);
packageReference = parsedProject.Items
.Single(t =>
t.ItemType == "PackageReference" &&
t.IsImported == false &&
t.EvaluatedInclude == "StrawberryShake.CodeGeneration.CSharp.Analyzers");
packageReference.SetMetadataValue("Version", GitVersion.SemVer);
parsedProject.Save();

DotNetBuild(c => c
.SetProjectFile(analyzerTestProject)
.SetConfiguration(Configuration)
.SetAssemblyVersion(GitVersion.AssemblySemVer)
.SetFileVersion(GitVersion.AssemblySemFileVer)
.SetInformationalVersion(GitVersion.InformationalVersion)
.SetVersion(GitVersion.SemVer));
});

Target Publish => _ => _
Expand Down
1 change: 1 addition & 0 deletions .build/Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class Helpers
Path.Combine("HotChocolate", "Spatial"),
Path.Combine("StrawberryShake", "Client"),
Path.Combine("StrawberryShake", "CodeGeneration"),
Path.Combine("StrawberryShake", "SourceGenerator"),
Path.Combine("StrawberryShake", "Tooling")
};

Expand Down
2 changes: 1 addition & 1 deletion .devops/azure-pipelines.release-hotchocolate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ stages:
pathtoPublish: "output/packages"
- job: Publish
displayName: "Publish"
dependsOn: [Test, Pack]
dependsOn: [Pack]
steps:
- task: DownloadBuildArtifacts@0
displayName: "Download Packages"
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -319,4 +319,6 @@ appsettings.user.json
# benchmark dbs
conferences.db
conferences.db-shm
conferences.db-wal
conferences.db-wal

.server/
38 changes: 37 additions & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"reveal": "silent"
},
"problemMatcher": "$msCompile"
}
},
{
"label": "build hc types analyzer",
"command": "dotnet",
Expand All @@ -56,6 +56,42 @@
"reveal": "silent"
},
"problemMatcher": "$msCompile"
},
{
"label": "build ss generator",
"command": "dotnet",
"type": "shell",
"args": [
"build",
"src/StrawberryShake/CodeGeneration",
// Ask dotnet build to generate full paths for file names.
"/property:GenerateFullPaths=true",
// Do not generate summary otherwise it leads to duplicate errors in Problems panel
"/consoleloggerparameters:NoSummary"
],
"group": "build",
"presentation": {
"reveal": "silent"
},
"problemMatcher": "$msCompile"
},
{
"label": "build ss source generator",
"command": "dotnet",
"type": "shell",
"args": [
"build",
"src/StrawberryShake/SourceGenerator",
// Ask dotnet build to generate full paths for file names.
"/property:GenerateFullPaths=true",
// Do not generate summary otherwise it leads to duplicate errors in Problems panel
"/consoleloggerparameters:NoSummary"
],
"group": "build",
"presentation": {
"reveal": "silent"
},
"problemMatcher": "$msCompile"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public async ValueTask<AuthorizeResult> AuthorizeAsync(
return AuthorizeResult.NotAuthenticated;
}

if (IsInAnyRole(principal, directive.Roles))
if (IsInAnyRole(principal!, directive.Roles))
{
if (NeedsPolicyValidation(directive))
{
Expand Down Expand Up @@ -93,11 +93,9 @@ private static bool IsInAnyRole(
}

private static bool NeedsPolicyValidation(AuthorizeDirective directive)
{
return directive.Roles == null
|| directive.Roles.Count == 0
|| !string.IsNullOrEmpty(directive.Policy);
}
=> directive.Roles == null
|| directive.Roles.Count == 0
|| !string.IsNullOrEmpty(directive.Policy);

private static async Task<AuthorizeResult> AuthorizeWithPolicyAsync(
IMiddlewareContext context,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Reflection;
using HotChocolate;
using HotChocolate.Execution.Configuration;
using HotChocolate.Internal;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public IInputFieldDescriptor Name(NameString value)
}

/// <inheritdoc />
public new IInputFieldDescriptor Deprecated(string reason)
public new IInputFieldDescriptor Deprecated(string? reason)
{
base.Deprecated(reason);
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -764,7 +764,7 @@ public class FieldNameInput
{
public string? YourFieldName { get; set; }

public string YourFieldname { get; set; }
public string YourFieldname { get; set; } = default!;
}

public class DeprecatedInputFields
Expand Down
6 changes: 0 additions & 6 deletions src/HotChocolate/Core/test/Validation.Tests/package.json

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System;

namespace HotChocolate.Stitching
{
public class SourceDirective
Expand Down
Loading

0 comments on commit e34f6ee

Please sign in to comment.