Skip to content

Commit

Permalink
Making all pathways through preview or write commands "know" when to …
Browse files Browse the repository at this point in the history
…and when not to use the server variable source
  • Loading branch information
jeremydmiller committed May 8, 2024
1 parent 4671bd9 commit 97c324f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<PropertyGroup>
<VersionPrefix>3.5.1</VersionPrefix>
<VersionPrefix>3.5.2</VersionPrefix>
<LangVersion>10.0</LangVersion>
<Authors>Jeremy D. Miller;Babu Annamalai;Oskar Dudycz;Joona-Pekka Kokko</Authors>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
Expand Down
2 changes: 1 addition & 1 deletion src/JasperFx.CodeGeneration/DynamicCodeBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public void WriteGeneratedCode(Action<string> onFileWritten)
var generatedAssembly = collection.StartAssembly(collection.Rules);
file.AssembleTypes(generatedAssembly);

var code = generatedAssembly.GenerateCode(ServiceVariableSource);
var code = collection is ICodeFileCollectionWithServices ? generatedAssembly.GenerateCode(ServiceVariableSource) : generatedAssembly.GenerateCode(null);
var fileName = Path.Combine(exportDirectory, file.FileName.Replace(" ", "_") + ".cs");
File.WriteAllText(fileName, code);
onFileWritten(fileName);
Expand Down
4 changes: 2 additions & 2 deletions src/JasperFx.RuntimeCompiler/CodeFileExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public static async Task Initialize(this ICodeFile file, GenerationRules rules,

var generatedAssembly = parent.StartAssembly(rules);
file.AssembleTypes(generatedAssembly);
var serviceVariables = services?.GetService(typeof(IServiceVariableSource)) as IServiceVariableSource;
var serviceVariables = parent is ICodeFileCollectionWithServices ? services?.GetService(typeof(IServiceVariableSource)) as IServiceVariableSource : null;

var compiler = new AssemblyGenerator();
compiler.Compile(generatedAssembly, serviceVariables);
Expand Down Expand Up @@ -89,7 +89,7 @@ public static void InitializeSynchronously(this ICodeFile file, GenerationRules

var generatedAssembly = parent.StartAssembly(rules);
file.AssembleTypes(generatedAssembly);
var serviceVariables = services?.GetService(typeof(IServiceVariableSource)) as IServiceVariableSource;
var serviceVariables = parent is ICodeFileCollectionWithServices ? services?.GetService(typeof(IServiceVariableSource)) as IServiceVariableSource : null;

var compiler = new AssemblyGenerator();
compiler.Compile(generatedAssembly, serviceVariables);
Expand Down

0 comments on commit 97c324f

Please sign in to comment.