diff --git a/src/Tasks.UnitTests/RoslynCodeTaskFactory_Tests.cs b/src/Tasks.UnitTests/RoslynCodeTaskFactory_Tests.cs index a77f9d5759e..7debf6e927d 100644 --- a/src/Tasks.UnitTests/RoslynCodeTaskFactory_Tests.cs +++ b/src/Tasks.UnitTests/RoslynCodeTaskFactory_Tests.cs @@ -20,7 +20,7 @@ using VerifyTests; using VerifyXunit; using Xunit; - +using Xunit.Abstractions; using static VerifyXunit.Verifier; #nullable disable @@ -34,11 +34,15 @@ public class RoslynCodeTaskFactory_Tests private readonly VerifySettings _verifySettings; - public RoslynCodeTaskFactory_Tests() + private readonly ITestOutputHelper _testOutputHelper; + + public RoslynCodeTaskFactory_Tests(ITestOutputHelper testOutputHelper) { + _testOutputHelper = testOutputHelper; UseProjectRelativeDirectory("TaskFactorySource"); _verifySettings = new(); + _verifySettings.UniqueForRuntime(); _verifySettings.ScrubLinesContaining("Runtime Version:"); } @@ -76,6 +80,7 @@ public void InlineTaskWithAssemblyPlatformAgnostic() "); + string output = RunnerUtilities.ExecMSBuild(inlineTask.Path, out bool success); success.ShouldBeTrue(output); output.ShouldContain("Alpha.GetString"); @@ -102,6 +107,8 @@ public void InlineTaskWithAssembly() "); + + _testOutputHelper.WriteLine($"AssemblyProj: {assemblyProj.Path}, {assemblyProj.ToString()}"); TransientTestFile csFile = env.CreateFile(folder, "Class1.cs", @" using System; @@ -113,7 +120,7 @@ public static string ToPrint() { } } "); - string output = RunnerUtilities.ExecMSBuild(assemblyProj.Path + $" /p:OutDir={Path.Combine(folder.Path, "subFolder")} /restore", out bool success); + string output = RunnerUtilities.ExecMSBuild(assemblyProj.Path + $" /p:OutDir={Path.Combine(folder.Path, "subFolder")} /restore", out bool success, _testOutputHelper); success.ShouldBeTrue(output); TransientTestFile inlineTask = env.CreateFile(folder, "5106.proj", @$" diff --git a/src/Tasks.UnitTests/TaskFactorySource/RoslynCodeTaskFactory_Tests.CSharpClass.verified.txt b/src/Tasks.UnitTests/TaskFactorySource/RoslynCodeTaskFactory_Tests.CSharpClass.DotNet.verified.txt similarity index 100% rename from src/Tasks.UnitTests/TaskFactorySource/RoslynCodeTaskFactory_Tests.CSharpClass.verified.txt rename to src/Tasks.UnitTests/TaskFactorySource/RoslynCodeTaskFactory_Tests.CSharpClass.DotNet.verified.txt diff --git a/src/Tasks.UnitTests/TaskFactorySource/RoslynCodeTaskFactory_Tests.CSharpClassSourceCodeFromFile.verified.txt b/src/Tasks.UnitTests/TaskFactorySource/RoslynCodeTaskFactory_Tests.CSharpClass.Net.verified.txt similarity index 100% rename from src/Tasks.UnitTests/TaskFactorySource/RoslynCodeTaskFactory_Tests.CSharpClassSourceCodeFromFile.verified.txt rename to src/Tasks.UnitTests/TaskFactorySource/RoslynCodeTaskFactory_Tests.CSharpClass.Net.verified.txt diff --git a/src/Tasks.UnitTests/TaskFactorySource/RoslynCodeTaskFactory_Tests.CSharpClassSourceCodeFromFile.DotNet.verified.txt b/src/Tasks.UnitTests/TaskFactorySource/RoslynCodeTaskFactory_Tests.CSharpClassSourceCodeFromFile.DotNet.verified.txt new file mode 100644 index 00000000000..ba355ca9bee --- /dev/null +++ b/src/Tasks.UnitTests/TaskFactorySource/RoslynCodeTaskFactory_Tests.CSharpClassSourceCodeFromFile.DotNet.verified.txt @@ -0,0 +1,13 @@ +namespace InlineTask +{ + using Microsoft.Build.Utilities; + + public class HelloWorld : Task + { + public override bool Execute() + { + Log.LogMessage("Hello, world!"); + return !Log.HasLoggedErrors; + } + } +} diff --git a/src/Tasks.UnitTests/TaskFactorySource/RoslynCodeTaskFactory_Tests.CSharpClassSourceCodeFromFile.Net.verified.txt b/src/Tasks.UnitTests/TaskFactorySource/RoslynCodeTaskFactory_Tests.CSharpClassSourceCodeFromFile.Net.verified.txt new file mode 100644 index 00000000000..ba355ca9bee --- /dev/null +++ b/src/Tasks.UnitTests/TaskFactorySource/RoslynCodeTaskFactory_Tests.CSharpClassSourceCodeFromFile.Net.verified.txt @@ -0,0 +1,13 @@ +namespace InlineTask +{ + using Microsoft.Build.Utilities; + + public class HelloWorld : Task + { + public override bool Execute() + { + Log.LogMessage("Hello, world!"); + return !Log.HasLoggedErrors; + } + } +} diff --git a/src/Tasks.UnitTests/TaskFactorySource/RoslynCodeTaskFactory_Tests.CSharpFragment.DotNet.verified.txt b/src/Tasks.UnitTests/TaskFactorySource/RoslynCodeTaskFactory_Tests.CSharpFragment.DotNet.verified.txt new file mode 100644 index 00000000000..283597f0671 --- /dev/null +++ b/src/Tasks.UnitTests/TaskFactorySource/RoslynCodeTaskFactory_Tests.CSharpFragment.DotNet.verified.txt @@ -0,0 +1,41 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace InlineCode { + using Microsoft.Build.Framework; + using Microsoft.Build.Utilities; + using System; + using System.Collections; + using System.Collections.Generic; + using System.IO; + using System.Linq; + using System.Text; + using System.Text.Json; + using System.Memory; + + + public class MyInlineTask : Microsoft.Build.Utilities.Task { + + private bool _Success = true; + + public virtual bool Success { + get { + return _Success; + } + set { + _Success = value; + } + } + + public override bool Execute() { +int x = 0; + return Success; + } + } +} diff --git a/src/Tasks.UnitTests/TaskFactorySource/RoslynCodeTaskFactory_Tests.CSharpFragment.verified.txt b/src/Tasks.UnitTests/TaskFactorySource/RoslynCodeTaskFactory_Tests.CSharpFragment.Net.verified.txt similarity index 100% rename from src/Tasks.UnitTests/TaskFactorySource/RoslynCodeTaskFactory_Tests.CSharpFragment.verified.txt rename to src/Tasks.UnitTests/TaskFactorySource/RoslynCodeTaskFactory_Tests.CSharpFragment.Net.verified.txt diff --git a/src/Tasks.UnitTests/TaskFactorySource/RoslynCodeTaskFactory_Tests.CSharpFragmentSourceCodeFromFile.DotNet.verified.txt b/src/Tasks.UnitTests/TaskFactorySource/RoslynCodeTaskFactory_Tests.CSharpFragmentSourceCodeFromFile.DotNet.verified.txt new file mode 100644 index 00000000000..283597f0671 --- /dev/null +++ b/src/Tasks.UnitTests/TaskFactorySource/RoslynCodeTaskFactory_Tests.CSharpFragmentSourceCodeFromFile.DotNet.verified.txt @@ -0,0 +1,41 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace InlineCode { + using Microsoft.Build.Framework; + using Microsoft.Build.Utilities; + using System; + using System.Collections; + using System.Collections.Generic; + using System.IO; + using System.Linq; + using System.Text; + using System.Text.Json; + using System.Memory; + + + public class MyInlineTask : Microsoft.Build.Utilities.Task { + + private bool _Success = true; + + public virtual bool Success { + get { + return _Success; + } + set { + _Success = value; + } + } + + public override bool Execute() { +int x = 0; + return Success; + } + } +} diff --git a/src/Tasks.UnitTests/TaskFactorySource/RoslynCodeTaskFactory_Tests.CSharpFragmentSourceCodeFromFile.verified.txt b/src/Tasks.UnitTests/TaskFactorySource/RoslynCodeTaskFactory_Tests.CSharpFragmentSourceCodeFromFile.Net.verified.txt similarity index 100% rename from src/Tasks.UnitTests/TaskFactorySource/RoslynCodeTaskFactory_Tests.CSharpFragmentSourceCodeFromFile.verified.txt rename to src/Tasks.UnitTests/TaskFactorySource/RoslynCodeTaskFactory_Tests.CSharpFragmentSourceCodeFromFile.Net.verified.txt diff --git a/src/Tasks.UnitTests/TaskFactorySource/RoslynCodeTaskFactory_Tests.CSharpFragmentWithProperties.DotNet.verified.txt b/src/Tasks.UnitTests/TaskFactorySource/RoslynCodeTaskFactory_Tests.CSharpFragmentWithProperties.DotNet.verified.txt new file mode 100644 index 00000000000..2d0d22a9eba --- /dev/null +++ b/src/Tasks.UnitTests/TaskFactorySource/RoslynCodeTaskFactory_Tests.CSharpFragmentWithProperties.DotNet.verified.txt @@ -0,0 +1,96 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace InlineCode { + using Microsoft.Build.Framework; + using Microsoft.Build.Utilities; + using System; + using System.Collections; + using System.Collections.Generic; + using System.IO; + using System.Linq; + using System.Text; + using System.Text.Json; + using System.Memory; + + + public class MyInlineTask : Microsoft.Build.Utilities.Task { + + private string _Parameter1; + + public virtual string Parameter1 { + get { + return _Parameter1; + } + set { + _Parameter1 = value; + } + } + + private string _Parameter2; + + public virtual string Parameter2 { + get { + return _Parameter2; + } + set { + _Parameter2 = value; + } + } + + private string _Parameter3; + + public virtual string Parameter3 { + get { + return _Parameter3; + } + set { + _Parameter3 = value; + } + } + + private Microsoft.Build.Framework.ITaskItem _Parameter4; + + public virtual Microsoft.Build.Framework.ITaskItem Parameter4 { + get { + return _Parameter4; + } + set { + _Parameter4 = value; + } + } + + private Microsoft.Build.Framework.ITaskItem[] _Parameter5; + + public virtual Microsoft.Build.Framework.ITaskItem[] Parameter5 { + get { + return _Parameter5; + } + set { + _Parameter5 = value; + } + } + + private bool _Success = true; + + public virtual bool Success { + get { + return _Success; + } + set { + _Success = value; + } + } + + public override bool Execute() { +int x = 0; + return Success; + } + } +} diff --git a/src/Tasks.UnitTests/TaskFactorySource/RoslynCodeTaskFactory_Tests.CSharpFragmentWithProperties.verified.txt b/src/Tasks.UnitTests/TaskFactorySource/RoslynCodeTaskFactory_Tests.CSharpFragmentWithProperties.Net.verified.txt similarity index 100% rename from src/Tasks.UnitTests/TaskFactorySource/RoslynCodeTaskFactory_Tests.CSharpFragmentWithProperties.verified.txt rename to src/Tasks.UnitTests/TaskFactorySource/RoslynCodeTaskFactory_Tests.CSharpFragmentWithProperties.Net.verified.txt diff --git a/src/Tasks.UnitTests/TaskFactorySource/RoslynCodeTaskFactory_Tests.CSharpMethod.DotNet.verified.txt b/src/Tasks.UnitTests/TaskFactorySource/RoslynCodeTaskFactory_Tests.CSharpMethod.DotNet.verified.txt new file mode 100644 index 00000000000..f3a0c9758de --- /dev/null +++ b/src/Tasks.UnitTests/TaskFactorySource/RoslynCodeTaskFactory_Tests.CSharpMethod.DotNet.verified.txt @@ -0,0 +1,27 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace InlineCode { + using Microsoft.Build.Framework; + using Microsoft.Build.Utilities; + using System; + using System.Collections; + using System.Collections.Generic; + using System.IO; + using System.Linq; + using System.Text; + using System.Text.Json; + using System.Memory; + + + public class MyInlineTask : Microsoft.Build.Utilities.Task { + +public override bool Execute() { int x = 0; return true; } + } +} diff --git a/src/Tasks.UnitTests/TaskFactorySource/RoslynCodeTaskFactory_Tests.CSharpMethod.verified.txt b/src/Tasks.UnitTests/TaskFactorySource/RoslynCodeTaskFactory_Tests.CSharpMethod.Net.verified.txt similarity index 100% rename from src/Tasks.UnitTests/TaskFactorySource/RoslynCodeTaskFactory_Tests.CSharpMethod.verified.txt rename to src/Tasks.UnitTests/TaskFactorySource/RoslynCodeTaskFactory_Tests.CSharpMethod.Net.verified.txt diff --git a/src/Tasks.UnitTests/TaskFactorySource/RoslynCodeTaskFactory_Tests.CSharpMethodSourceCodeFromFile.DotNet.verified.txt b/src/Tasks.UnitTests/TaskFactorySource/RoslynCodeTaskFactory_Tests.CSharpMethodSourceCodeFromFile.DotNet.verified.txt new file mode 100644 index 00000000000..f3a0c9758de --- /dev/null +++ b/src/Tasks.UnitTests/TaskFactorySource/RoslynCodeTaskFactory_Tests.CSharpMethodSourceCodeFromFile.DotNet.verified.txt @@ -0,0 +1,27 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace InlineCode { + using Microsoft.Build.Framework; + using Microsoft.Build.Utilities; + using System; + using System.Collections; + using System.Collections.Generic; + using System.IO; + using System.Linq; + using System.Text; + using System.Text.Json; + using System.Memory; + + + public class MyInlineTask : Microsoft.Build.Utilities.Task { + +public override bool Execute() { int x = 0; return true; } + } +} diff --git a/src/Tasks.UnitTests/TaskFactorySource/RoslynCodeTaskFactory_Tests.CSharpMethodSourceCodeFromFile.verified.txt b/src/Tasks.UnitTests/TaskFactorySource/RoslynCodeTaskFactory_Tests.CSharpMethodSourceCodeFromFile.Net.verified.txt similarity index 100% rename from src/Tasks.UnitTests/TaskFactorySource/RoslynCodeTaskFactory_Tests.CSharpMethodSourceCodeFromFile.verified.txt rename to src/Tasks.UnitTests/TaskFactorySource/RoslynCodeTaskFactory_Tests.CSharpMethodSourceCodeFromFile.Net.verified.txt diff --git a/src/Tasks.UnitTests/TaskFactorySource/RoslynCodeTaskFactory_Tests.SourceCodeFromFile.verified.txt b/src/Tasks.UnitTests/TaskFactorySource/RoslynCodeTaskFactory_Tests.SourceCodeFromFile.DotNet.verified.txt similarity index 100% rename from src/Tasks.UnitTests/TaskFactorySource/RoslynCodeTaskFactory_Tests.SourceCodeFromFile.verified.txt rename to src/Tasks.UnitTests/TaskFactorySource/RoslynCodeTaskFactory_Tests.SourceCodeFromFile.DotNet.verified.txt diff --git a/src/Tasks.UnitTests/TaskFactorySource/RoslynCodeTaskFactory_Tests.SourceCodeFromFile.Net.verified.txt b/src/Tasks.UnitTests/TaskFactorySource/RoslynCodeTaskFactory_Tests.SourceCodeFromFile.Net.verified.txt new file mode 100644 index 00000000000..4358c4b04fb --- /dev/null +++ b/src/Tasks.UnitTests/TaskFactorySource/RoslynCodeTaskFactory_Tests.SourceCodeFromFile.Net.verified.txt @@ -0,0 +1,3 @@ + +1F214E27A13F432B9397F1733BC55929 +9111DC29B0064E6994A68CFE465404D4 \ No newline at end of file diff --git a/src/Tasks.UnitTests/TaskFactorySource/RoslynCodeTaskFactory_Tests.VisualBasicFragment.DotNet.verified.txt b/src/Tasks.UnitTests/TaskFactorySource/RoslynCodeTaskFactory_Tests.VisualBasicFragment.DotNet.verified.txt new file mode 100644 index 00000000000..265c9456084 --- /dev/null +++ b/src/Tasks.UnitTests/TaskFactorySource/RoslynCodeTaskFactory_Tests.VisualBasicFragment.DotNet.verified.txt @@ -0,0 +1,45 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict Off +Option Explicit On + +Imports Microsoft.Build.Framework +Imports Microsoft.Build.Utilities +Imports System +Imports System.Collections +Imports System.Collections.Generic +Imports System.IO +Imports System.Linq +Imports System.Memory +Imports System.Text +Imports System.Text.Json + +Namespace InlineCode + + Public Class MyInlineTask + Inherits Microsoft.Build.Utilities.Task + + Private _Success As Boolean = true + + Public Overridable Property Success() As Boolean + Get + Return _Success + End Get + Set + _Success = value + End Set + End Property + + Public Overrides Function Execute() As Boolean +Dim x = 0 + Return Success + End Function + End Class +End Namespace diff --git a/src/Tasks.UnitTests/TaskFactorySource/RoslynCodeTaskFactory_Tests.VisualBasicFragment.verified.txt b/src/Tasks.UnitTests/TaskFactorySource/RoslynCodeTaskFactory_Tests.VisualBasicFragment.Net.verified.txt similarity index 100% rename from src/Tasks.UnitTests/TaskFactorySource/RoslynCodeTaskFactory_Tests.VisualBasicFragment.verified.txt rename to src/Tasks.UnitTests/TaskFactorySource/RoslynCodeTaskFactory_Tests.VisualBasicFragment.Net.verified.txt diff --git a/src/Tasks.UnitTests/TaskFactorySource/RoslynCodeTaskFactory_Tests.VisualBasicFragmentWithProperties.DotNet.verified.txt b/src/Tasks.UnitTests/TaskFactorySource/RoslynCodeTaskFactory_Tests.VisualBasicFragmentWithProperties.DotNet.verified.txt new file mode 100644 index 00000000000..93667732026 --- /dev/null +++ b/src/Tasks.UnitTests/TaskFactorySource/RoslynCodeTaskFactory_Tests.VisualBasicFragmentWithProperties.DotNet.verified.txt @@ -0,0 +1,100 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict Off +Option Explicit On + +Imports Microsoft.Build.Framework +Imports Microsoft.Build.Utilities +Imports System +Imports System.Collections +Imports System.Collections.Generic +Imports System.IO +Imports System.Linq +Imports System.Memory +Imports System.Text +Imports System.Text.Json + +Namespace InlineCode + + Public Class MyInlineTask + Inherits Microsoft.Build.Utilities.Task + + Private _Parameter1 As String + + Public Overridable Property Parameter1() As String + Get + Return _Parameter1 + End Get + Set + _Parameter1 = value + End Set + End Property + + Private _Parameter2 As String + + Public Overridable Property Parameter2() As String + Get + Return _Parameter2 + End Get + Set + _Parameter2 = value + End Set + End Property + + Private _Parameter3 As String + + Public Overridable Property Parameter3() As String + Get + Return _Parameter3 + End Get + Set + _Parameter3 = value + End Set + End Property + + Private _Parameter4 As Microsoft.Build.Framework.ITaskItem + + Public Overridable Property Parameter4() As Microsoft.Build.Framework.ITaskItem + Get + Return _Parameter4 + End Get + Set + _Parameter4 = value + End Set + End Property + + Private _Parameter5() As Microsoft.Build.Framework.ITaskItem + + Public Overridable Property Parameter5() As Microsoft.Build.Framework.ITaskItem() + Get + Return _Parameter5 + End Get + Set + _Parameter5 = value + End Set + End Property + + Private _Success As Boolean = true + + Public Overridable Property Success() As Boolean + Get + Return _Success + End Get + Set + _Success = value + End Set + End Property + + Public Overrides Function Execute() As Boolean +Dim x = 0 + Return Success + End Function + End Class +End Namespace diff --git a/src/Tasks.UnitTests/TaskFactorySource/RoslynCodeTaskFactory_Tests.VisualBasicFragmentWithProperties.verified.txt b/src/Tasks.UnitTests/TaskFactorySource/RoslynCodeTaskFactory_Tests.VisualBasicFragmentWithProperties.Net.verified.txt similarity index 100% rename from src/Tasks.UnitTests/TaskFactorySource/RoslynCodeTaskFactory_Tests.VisualBasicFragmentWithProperties.verified.txt rename to src/Tasks.UnitTests/TaskFactorySource/RoslynCodeTaskFactory_Tests.VisualBasicFragmentWithProperties.Net.verified.txt diff --git a/src/Tasks.UnitTests/TaskFactorySource/RoslynCodeTaskFactory_Tests.VisualBasicMethod.DotNet.verified.txt b/src/Tasks.UnitTests/TaskFactorySource/RoslynCodeTaskFactory_Tests.VisualBasicMethod.DotNet.verified.txt new file mode 100644 index 00000000000..117dce8bfe6 --- /dev/null +++ b/src/Tasks.UnitTests/TaskFactorySource/RoslynCodeTaskFactory_Tests.VisualBasicMethod.DotNet.verified.txt @@ -0,0 +1,34 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict Off +Option Explicit On + +Imports Microsoft.Build.Framework +Imports Microsoft.Build.Utilities +Imports System +Imports System.Collections +Imports System.Collections.Generic +Imports System.IO +Imports System.Linq +Imports System.Memory +Imports System.Text +Imports System.Text.Json + +Namespace InlineCode + + Public Class MyInlineTask + Inherits Microsoft.Build.Utilities.Task + +Public Overrides Function Execute() As Boolean + Dim x = 0 + Return True + End Function + End Class +End Namespace diff --git a/src/Tasks.UnitTests/TaskFactorySource/RoslynCodeTaskFactory_Tests.VisualBasicMethod.verified.txt b/src/Tasks.UnitTests/TaskFactorySource/RoslynCodeTaskFactory_Tests.VisualBasicMethod.Net.verified.txt similarity index 100% rename from src/Tasks.UnitTests/TaskFactorySource/RoslynCodeTaskFactory_Tests.VisualBasicMethod.verified.txt rename to src/Tasks.UnitTests/TaskFactorySource/RoslynCodeTaskFactory_Tests.VisualBasicMethod.Net.verified.txt diff --git a/src/Tasks/RoslynCodeTaskFactory/RoslynCodeTaskFactory.cs b/src/Tasks/RoslynCodeTaskFactory/RoslynCodeTaskFactory.cs index 535156bc1fd..de50ca4d4a6 100644 --- a/src/Tasks/RoslynCodeTaskFactory/RoslynCodeTaskFactory.cs +++ b/src/Tasks/RoslynCodeTaskFactory/RoslynCodeTaskFactory.cs @@ -38,6 +38,11 @@ public sealed class RoslynCodeTaskFactory : ITaskFactory "System.IO", "System.Linq", "System.Text", + + #if RUNTIME_TYPE_NETCORE || NETCOREAPP + "System.Text.Json", + "System.Memory", + #endif }; /// @@ -53,7 +58,11 @@ public sealed class RoslynCodeTaskFactory : ITaskFactory "Microsoft.Build.Framework", "Microsoft.Build.Utilities.Core", "mscorlib", - "netstandard" + "netstandard", + #if RUNTIME_TYPE_NETCORE || NETCOREAPP + "System.Text.Json", + "System.Memory", + #endif } }, // CSharp specific assembly references @@ -244,6 +253,7 @@ internal static string GetSourceCode(RoslynCodeTaskFactoryTaskInfo taskInfo, ICo } CodeNamespace codeNamespace = new CodeNamespace("InlineCode"); + codeNamespace.Imports.AddRange(DefaultNamespaces.Union(taskInfo.Namespaces, StringComparer.OrdinalIgnoreCase).Select(i => new CodeNamespaceImport(i)).ToArray()); codeNamespace.Types.Add(codeTypeDeclaration);