Skip to content

Commit

Permalink
fix issue with code debug output failing to create dirs (#109)
Browse files Browse the repository at this point in the history
* ms code analysis packages no longer private

* remove dev dep flag as breaking builds

* update pkg descriptions

* batch test output by guid per build

* package marked as deterministic for ci

* mark build as deterministic

* move test ci flag before opencover args

* actually put the ci flag on the build and not the test

* fix test line

* removed private asset implicit behaviour

* remove folder guid. vs failing to create new dirs

* remove generator attribute off abstract types
  • Loading branch information
dpvreony committed Jan 31, 2021
1 parent de92354 commit 4481f1c
Show file tree
Hide file tree
Showing 15 changed files with 3 additions and 18 deletions.
Expand Up @@ -6,7 +6,6 @@ namespace Dhgms.Nucleotide.Generators.Features.Cqrs
/// <summary>
/// Generator for Command Factory Interface
/// </summary>
[Generator]
public abstract class CommandFactoryInterfaceGenerator : BaseInterfaceLevelCodeGenerator<CommandFactoryInterfaceFeatureFlags, CommandFactoryInterfaceGeneratorProcessor>
{
protected override string GetNamespace()
Expand Down
Expand Up @@ -3,7 +3,6 @@

namespace Dhgms.Nucleotide.Generators.Features.Cqrs
{
[Generator]
public abstract class CommandInterfaceGenerator : BaseInterfaceLevelCodeGenerator<CommandInterfaceFeatureFlags, CommandInterfaceGeneratorProcessor>
{
protected override string GetNamespace() => "Commands";
Expand Down
Expand Up @@ -6,7 +6,6 @@ namespace Dhgms.Nucleotide.Generators.Features.Cqrs
/// <summary>
/// Generator for Query Factory Interface
/// </summary>
[Generator]
public abstract class QueryFactoryInterfaceGenerator : BaseInterfaceLevelCodeGenerator<QueryFactoryInterfaceFeatureFlags, QueryFactoryInterfaceGeneratorProcessor>
{
protected override string GetNamespace()
Expand Down
Expand Up @@ -6,7 +6,6 @@ namespace Dhgms.Nucleotide.Generators.Features.Cqrs
/// <summary>
/// Generator for Query Interface
/// </summary>
[Generator]
public abstract class QueryInterfaceGenerator : BaseInterfaceLevelCodeGenerator<QueryInterfaceFeatureFlag, QueryInterfaceGeneratorProcessor>
{
protected override string GetNamespace() => "Queries";
Expand Down
Expand Up @@ -6,7 +6,6 @@ namespace Dhgms.Nucleotide.Generators.Features.EntityFramework
/// <summary>
/// Code Generator for Entity Framework DB Context
/// </summary>
[Generator]
public abstract class EntityFrameworkDbContextGenerator : BaseGenerator<EntityFrameworkDbContextFeatureFlags, EntityFrameworkDbContextGeneratorProcessor>
{
protected override string GetNamespace()
Expand Down
Expand Up @@ -3,7 +3,6 @@

namespace Dhgms.Nucleotide.Generators.Features.EntityFramework
{
[Generator]
public abstract class EntityFrameworkEntityTypeConfigurationGenerator : BaseClassLevelCodeGenerator<EntityFrameworkEntityTypeConfigurationFeatureFlags, EntityFrameworkEntityTypeConfigurationGeneratorProcessor>
{
protected override string GetNamespace()
Expand Down
Expand Up @@ -3,7 +3,6 @@

namespace Dhgms.Nucleotide.Generators.Features.EntityFramework
{
[Generator]
public abstract class EntityFrameworkModelGenerator : BaseClassLevelCodeGenerator<EntityFrameworkModelFeatureFlags, EntityFrameworkModelGeneratorProcessor>
{
protected override string GetNamespace()
Expand Down
Expand Up @@ -6,7 +6,6 @@ namespace Dhgms.Nucleotide.Generators.Features.Model
/// <summary>
/// Generates models
/// </summary>
[Generator]
public abstract class KeyedModelClassGenerator : BaseClassLevelCodeGenerator<KeyedModelClassFeatureFlags, KeyedModelClassGeneratorProcessor>
{
protected override string GetNamespace() => "Models";
Expand Down
Expand Up @@ -3,7 +3,6 @@

namespace Dhgms.Nucleotide.Generators.Features.Model
{
[Generator]
public abstract class KeyedModelInterfaceGenerator : BaseInterfaceLevelCodeGenerator<KeyedModelInterfaceFeatureFlags, KeyedModelInterfaceGeneratorProcessor>
{
protected override string GetNamespace()
Expand Down
Expand Up @@ -6,7 +6,6 @@ namespace Dhgms.Nucleotide.Generators.Features.Model
/// <summary>
/// Generates models
/// </summary>
[Generator]
public abstract class UnkeyedModelClassGenerator : BaseClassLevelCodeGenerator<UnkeyedModelClassFeatureFlags, UnkeyedModelClassGeneratorProcessor>
{
protected override string GetNamespace() => "Models";
Expand Down
Expand Up @@ -3,7 +3,6 @@

namespace Dhgms.Nucleotide.Generators.Features.Model
{
[Generator]
public abstract class UnkeyedModelInterfaceGenerator : BaseInterfaceLevelCodeGenerator<UnkeyedModelInterfaceFeatureFlags, UnkeyedModelInterfaceGeneratorProcessor>
{
protected override string GetNamespace()
Expand Down
Expand Up @@ -3,7 +3,6 @@

namespace Dhgms.Nucleotide.Generators.Features.WebApi
{
[Generator]
public abstract class WebApiClientGenerator : BaseClassLevelCodeGenerator<WebApiClientFeatureFlags, WebApiClientGeneratorProcessor>
{
protected override string GetNamespace()
Expand Down
Expand Up @@ -6,7 +6,6 @@ namespace Dhgms.Nucleotide.Generators.Features.WebApi
/// <summary>
/// Generates the Web API service
/// </summary>
[Generator]
public abstract class WebApiServiceGenerator : BaseClassLevelCodeGenerator<WebApiServiceFeatureFlags, WebApiServiceGeneratorProcessor>
{
protected override string GetNamespace()
Expand Down
4 changes: 1 addition & 3 deletions src/Dhgms.Nucleotide.Generators/Generators/BaseGenerator.cs
Expand Up @@ -50,7 +50,6 @@ public static Diagnostic ErrorDiagnostic(string message)

public void Execute(GeneratorExecutionContext context)
{
var compilation = context.Compilation;
context.ReportDiagnostic(InfoDiagnostic(typeof(TGeneratorProcessor).ToString()));

// TODO: this is running async code inside non-async
Expand All @@ -59,7 +58,6 @@ public void Execute(GeneratorExecutionContext context)
.GetResult();

var parseOptions = context.ParseOptions;
var folderGuid = Guid.NewGuid();

foreach (var memberDeclarationSyntax in result)
{
Expand All @@ -76,7 +74,7 @@ public void Execute(GeneratorExecutionContext context)
var sourceText = SyntaxFactory.SyntaxTree(cu, parseOptions, encoding: Encoding.UTF8).GetText();

// https://github.com/dotnet/roslyn-sdk/pull/553/files
var generatedSourceOutputPath = context.TryCreateGeneratedSourceOutputPath(folderGuid);
var generatedSourceOutputPath = context.TryCreateGeneratedSourceOutputPath();
context.AddSource(
generatedSourceOutputPath,
$"nucleotide.{feature}.{guid}.g.cs",
Expand Down
Expand Up @@ -9,15 +9,15 @@ namespace Dhgms.Nucleotide.Generators
{
internal static class SourceGeneratorContextExtensions
{
public static string TryCreateGeneratedSourceOutputPath(this GeneratorExecutionContext context, Guid folderGuid)
public static string TryCreateGeneratedSourceOutputPath(this GeneratorExecutionContext context)
{
string generatedSourceOutputPath = null;
if (context.AnalyzerConfigOptions.GlobalOptions.TryGetValue("build_property.SaveSourceGeneratorOutput", out string saveSourceGeneratorOutputValue)
&& bool.TryParse(saveSourceGeneratorOutputValue, out bool saveSourceGeneratorOutput)
&& saveSourceGeneratorOutput
&& context.AnalyzerConfigOptions.GlobalOptions.TryGetValue("build_property.IntermediateOutputPath", out string intermediateOutputPath))
{
generatedSourceOutputPath = Path.Combine(intermediateOutputPath, "Generated", folderGuid.ToString());
generatedSourceOutputPath = Path.Combine(intermediateOutputPath, "Generated");
Directory.CreateDirectory(generatedSourceOutputPath);
}

Expand Down

0 comments on commit 4481f1c

Please sign in to comment.