Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
f772498
Make folder for GenerateResource tests
rainersigwald Apr 25, 2019
f5829d3
Teach Entry to add itself to an IResourceWriter
rainersigwald Apr 30, 2019
f7661c3
AddResource overload that takes an Entry
rainersigwald Apr 30, 2019
e312d52
Introduce IResource
rainersigwald Apr 30, 2019
17c476c
Skeleton for TDD
rainersigwald Apr 30, 2019
af5f714
Simple string-only tests
rainersigwald Apr 30, 2019
4836229
Refactor parsing to be more general
rainersigwald Apr 30, 2019
f30bc63
Special case further into strings
rainersigwald Apr 30, 2019
979a0a6
start thinking about resxfileref
rainersigwald Apr 30, 2019
ba8fb47
take a stab at aliases
rainersigwald Apr 30, 2019
b28a931
Work toward RESXFILEREF
rainersigwald May 8, 2019
4b0c530
Simplify StringResource testing
rainersigwald May 8, 2019
fc18a86
Support reading text files as strings via ResXFileRef
rainersigwald May 8, 2019
96d5c0b
Assert presence of reference files
rainersigwald May 9, 2019
e039ab2
Generalize resource adding to IResource
rainersigwald May 9, 2019
0144a73
Add IResource.Name
rainersigwald May 9, 2019
9ea929f
extract GetResourcesFromFile
rainersigwald May 9, 2019
b986bc8
test todos
rainersigwald May 9, 2019
c942c28
Generalize AddResource to IResource
rainersigwald May 9, 2019
5fbd4b0
Use MSBuildResXReader in .NET Core
rainersigwald May 9, 2019
81e94bc
support shift_jis on core
rainersigwald May 9, 2019
b756b34
Disable tests smarter for #4094
rainersigwald May 9, 2019
3384a41
Be more tolerant resolving types in the non-aliased case (ResXResourc…
rainersigwald May 10, 2019
54fe22a
ParsesSingleStringWithPartialTypeName
rainersigwald May 10, 2019
dd42273
Super general ResXFileRef support
rainersigwald May 12, 2019
2252f5c
Handle underqualified string typename
rainersigwald May 12, 2019
d56ff86
extract AddLinkedResource
rainersigwald May 12, 2019
38143a6
Throw on unrecognized data
rainersigwald May 12, 2019
c66b71c
Handle tiny bitmap (test passes, no real use yet)
rainersigwald May 12, 2019
ed1d832
Switch to static method entirely
rainersigwald May 12, 2019
0fad86b
Use new writer on core (should be 'when building for core' but isn't …
rainersigwald May 15, 2019
618c82f
Stop trying to load types at build time
rainersigwald May 22, 2019
0d63056
Add StringTypeName const
rainersigwald May 23, 2019
5dd44c1
Port MimeType consts from ResxResourceWriter
rainersigwald May 23, 2019
f4aeb19
Switch for mimetype
rainersigwald May 23, 2019
f91fc56
Streamline string handling
rainersigwald May 23, 2019
b791612
BinaryFormatter, type specified (doesn't seem to be a real case)
rainersigwald May 23, 2019
5b0b04e
Extract Entry to LiveObjectResource
rainersigwald May 23, 2019
41f5117
Special case for array[], mirroring ResXResourceReader
rainersigwald May 23, 2019
5e75e14
TypeConverterString test
rainersigwald May 24, 2019
b005648
Support packing value directly into the <data> tag
rainersigwald May 24, 2019
7073bac
Plumb through filestream refs
rainersigwald May 24, 2019
bd9fe49
plumb through path-relative-to-file-or-CWD option
rainersigwald May 24, 2019
2980e98
TODO for binaryformatter byte[]
rainersigwald Jun 4, 2019
9bfba40
Register encodings in the dev code
rainersigwald Jun 4, 2019
527b267
Switch System.Resources.Extensions version reference to a maestro-fri…
rainersigwald Jun 6, 2019
e0db4a8
System.Resources.Extensions 4.6.0-preview1.19306.4
rainersigwald Jun 6, 2019
7f6739b
xplat paths for tests
rainersigwald Jun 6, 2019
94f1b5b
Change slash direction for ResXFileRef paths
rainersigwald Jun 6, 2019
5b11a04
Detailed error message for unknown mimetype
rainersigwald Jun 7, 2019
f3ef876
Better alias handling
rainersigwald Jun 7, 2019
5ed837b
Stricter recognition of System.String
rainersigwald Jun 7, 2019
0740f06
Remove vestigial Resources property
rainersigwald Jun 7, 2019
a32077e
Allow and ignore unrecognized resx elements
rainersigwald Jun 7, 2019
4c44a99
Update to approved S.Resources.Extension API
rainersigwald Jun 11, 2019
4eebca2
MSBUILDUSEMINIMALRESX escape hatch
rainersigwald Jun 11, 2019
579543a
Reflow arguments to ProcessResourceFiles.Run (style change only)
rainersigwald Jun 12, 2019
cbb0a96
Explicit opt-in to new resx
rainersigwald Jun 13, 2019
b027d2f
Doc comments for FileStreamResource
rainersigwald Jun 19, 2019
0793f01
Use new ResX reader when finding linked files
rainersigwald Jun 19, 2019
3ed0e31
Improved diagnosability for ForceOutOfDateLinked tests
rainersigwald Jun 20, 2019
c712f08
Don't uppercase paths on non-Windows (as a proxy for case sensitive)
rainersigwald Jun 20, 2019
ac0800c
Artificially increment timestamp in test
rainersigwald Jun 20, 2019
98e84cd
Discover linked resources for Core
rainersigwald Jun 20, 2019
8065d64
Dispose test env in RequiredTransformations
rainersigwald Jun 21, 2019
a4c3e7e
Update LiveObjectResource.Value to modern style
rainersigwald Jun 21, 2019
0b26127
Extract AddResourcesUsingMinimalCoreResxParsing
rainersigwald Jun 21, 2019
3a50b6f
Generate shift-JIS file at test time to avoid the vagaries of VCS enc…
rainersigwald Jun 21, 2019
0213926
GetResourcesFromString should be relative to path by default if one i…
rainersigwald Jun 21, 2019
6ec1255
Shouldly in TransientTestFolder
rainersigwald Jun 21, 2019
255de24
Remove bogus Equals/GetHashCode for StringResource
rainersigwald Jun 21, 2019
221eb77
Introduce MSBuildResXException
rainersigwald Jun 21, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions eng/Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
<PackageReference Update="System.Net.Http" Version="4.3.0" />
<PackageReference Update="System.Reflection.Metadata" Version="1.6.0" />
<PackageReference Update="System.Reflection.TypeExtensions" Version="4.1.0" />
<PackageReference Update="System.Resources.Extensions" Version="$(SystemResourcesExtensionsVersion)" />
<PackageReference Update="System.Resources.Writer" Version="4.0.0" />
<PackageReference Update="System.Runtime.InteropServices.RuntimeInformation" Version="4.3.0" />
<PackageReference Update="System.Runtime.Loader" Version="4.0.0" />
Expand Down
6 changes: 6 additions & 0 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,10 @@
<Sha>b5016f5688dc8ca9f3e4811ee7e2e86ad8907a40</Sha>
</Dependency>
</ToolsetDependencies>
<ProductDependencies>
<Dependency Name="System.Resources.Extensions" Version="4.6.0-preview7.19311.1">
<Uri>https://github.com/dotnet/corefx</Uri>
<Sha>a78bd7308555926f88aad3d0ecaaebae0f9204cc</Sha>
</Dependency>
</ProductDependencies>
</Dependencies>
5 changes: 5 additions & 0 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<RestoreSources>$(DotNetRestoreSources)</RestoreSources>
<RestoreSources Condition="'$(DotNetBuildOffline)' != 'true'">
$(RestoreSources);
https://dotnetfeed.blob.core.windows.net/dotnet-core/index.json;
https://dotnet.myget.org/F/roslyn/api/v3/index.json;
https://dotnet.myget.org/F/nuget-build/api/v3/index.json;
https://dotnet.myget.org/F/roslyn-tools/api/v3/index.json;
Expand All @@ -32,4 +33,8 @@
<PropertyGroup>
<DotNetCliVersion>3.0.100-preview5-011568</DotNetCliVersion>
</PropertyGroup>
<!-- Product Dependencies -->
<PropertyGroup>
<SystemResourcesExtensionsVersion>4.6.0-preview7.19311.1</SystemResourcesExtensionsVersion>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,7 @@ public GenerateResource() { }
public string TrackerLogDirectory { get { throw null; } set { } }
public string TrackerSdkPath { get { throw null; } set { } }
public bool TrackFileAccess { get { throw null; } set { } }
public bool UsePreserializedResources { get { throw null; } set { } }
public bool UseSourcePath { get { throw null; } set { } }
public override bool Execute() { throw null; }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ public GenerateResource() { }
public string TrackerLogDirectory { get { throw null; } set { } }
public string TrackerSdkPath { get { throw null; } set { } }
public bool TrackFileAccess { get { throw null; } set { } }
public bool UsePreserializedResources { get { throw null; } set { } }
public bool UseSourcePath { get { throw null; } set { } }
public override bool Execute() { throw null; }
}
Expand Down
1 change: 0 additions & 1 deletion src/Directory.BeforeCommon.targets
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
<DefineConstants>$(DefineConstants);FEATURE_LEGACY_GETCURRENTDIRECTORY</DefineConstants>
<!-- Path.GetFullPath The pre .Net 4.6.2 implementation of Path.GetFullPath is slow and creates strings in its work. -->
<DefineConstants>$(DefineConstants);FEATURE_LEGACY_GETFULLPATH</DefineConstants>
<DefineConstants>$(DefineConstants);FEATURE_LINKED_RESOURCES</DefineConstants>
<DefineConstants>$(DefineConstants);FEATURE_NAMED_PIPE_SECURITY_CONSTRUCTOR</DefineConstants>
<DefineConstants>$(DefineConstants);FEATURE_OSVERSION</DefineConstants>
<DefineConstants>$(DefineConstants);FEATURE_PERFORMANCE_COUNTERS</DefineConstants>
Expand Down
8 changes: 8 additions & 0 deletions src/Shared/Traits.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,14 @@ internal class EscapeHatches
/// </summary>
public readonly bool EnsureStdOutForChildNodesIsPrimaryStdout = Environment.GetEnvironmentVariable("MSBUILDENSURESTDOUTFORTASKPROCESSES") == "1";

/// <summary>
/// Use the original, string-only resx parsing in .NET Core scenarios.
/// </summary>
/// <remarks>
/// Escape hatch for problems arising from https://github.com/microsoft/msbuild/pull/4420.
/// </remarks>
public readonly bool UseMinimalResxParsingInCoreScenarios = Environment.GetEnvironmentVariable("MSBUILDUSEMINIMALRESX") == "1";

private static bool? ParseNullableBoolFromEnvironmentVariable(string environmentVariable)
{
var value = Environment.GetEnvironmentVariable(environmentVariable);
Expand Down
11 changes: 5 additions & 6 deletions src/Shared/UnitTests/TestEnvironment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -612,12 +612,11 @@ public override void Revert()
{
// Basic checks to make sure we're not deleting something very obviously wrong (e.g.
// the entire temp drive).
Assert.NotNull(Path);
Assert.NotEqual(string.Empty, Path);
Assert.NotEqual(@"\", Path);
Assert.NotEqual(@"/", Path);
Assert.NotEqual(System.IO.Path.GetFullPath(System.IO.Path.GetTempPath()), System.IO.Path.GetFullPath(Path));
Assert.True(System.IO.Path.IsPathRooted(Path));
Path.ShouldNotBeNullOrEmpty();
Path.ShouldNotBe(@"\");
Path.ShouldNotBe(@"/");
System.IO.Path.GetFullPath(Path).ShouldNotBe(System.IO.Path.GetFullPath(System.IO.Path.GetTempPath()));
System.IO.Path.IsPathRooted(Path).ShouldBeTrue(() => $"{Path} is not rooted");

FileUtilities.DeleteDirectoryNoThrow(Path, true);
}
Expand Down
7 changes: 4 additions & 3 deletions src/Tasks.UnitTests/Microsoft.Build.Tasks.UnitTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,14 @@
<Compile Remove="DependentAssembly_Tests.cs" />
<Compile Remove="ErrorWarningMessage_Tests.cs" />
<Compile Remove="FindInvalidProjectReferences_Tests.cs" />
<Compile Remove="GenerateResourceOutOfProc_Tests.cs" />
<Compile Remove="ResourceHandling\GenerateResourceOutOfProc_Tests.cs" />
<Compile Remove="ResourceHandling\ResGen_Tests.cs" />
<Compile Remove="ResourceHandling\ResGenDependencies_Tests.cs" />
<Compile Remove="GetInstalledSDKLocations_Tests.cs" />
<Compile Remove="GetSDKReference_Tests.cs" />
<Compile Remove="LC_Tests.cs" />
<Compile Remove="MockTypeInfo.cs" />
<Compile Remove="MockTypeLib.cs" />
<Compile Remove="ResGen_Tests.cs" />
<Compile Remove="ResGenDependencies_Tests.cs" />
<Compile Remove="AssemblyDependency\AssemblyFoldersFromConfig_Tests.cs" />
<Compile Remove="AssemblyDependency\FilePrimary.cs" />
<Compile Remove="AssemblyDependency\GlobalAssemblyCacheTests.cs" />
Expand Down Expand Up @@ -140,6 +140,7 @@
</ItemGroup>

<ItemGroup>
<None Update="ResourceHandling\*.txt" CopyToOutputDirectory="PreserveNewest" />
<None Update="TestResources\lorem.bin">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace Microsoft.Build.UnitTests.GenerateResource_Tests.InProc
{
[Trait("Category", "mono-osx-failing")]
[Trait("Category", "mono-windows-failing")]
public sealed class RequiredTransformations
public sealed class RequiredTransformations : IDisposable
{
private readonly TestEnvironment _env;
private readonly ITestOutputHelper _output;
Expand All @@ -31,6 +31,11 @@ public RequiredTransformations(ITestOutputHelper output)
_output = output;
}

public void Dispose()
{
_env.Dispose();
}

/// <summary>
/// ResX to Resources, no references
/// </summary>
Expand Down Expand Up @@ -363,17 +368,14 @@ public void ForceOutOfDateByDeletion()
/// <summary>
/// Force out-of-date with ShouldRebuildResgenOutputFile on the linked file
/// </summary>
#if FEATURE_LINKED_RESOURCES
[Fact]
#else
[Fact(Skip = "https://github.com/Microsoft/msbuild/issues/1247")]
#endif
public void ForceOutOfDateLinked()
[Theory]
[MemberData(nameof(Utilities.UsePreserializedResourceStates), MemberType = typeof(Utilities))]
public void ForceOutOfDateLinked(bool usePreserialized)
{
string bitmap = Utilities.CreateWorldsSmallestBitmap();
string resxFile = Utilities.WriteTestResX(false, bitmap, null, false);

GenerateResource t = Utilities.CreateTask(_output);
GenerateResource t = Utilities.CreateTask(_output, usePreserialized, _env);
t.StateFile = new TaskItem(Utilities.GetTempFileName(".cache"));

try
Expand All @@ -382,27 +384,29 @@ public void ForceOutOfDateLinked()

Utilities.ExecuteTask(t);

string resourcesFile = t.OutputResources[0].ItemSpec;
Assert.Equal(".resources", Path.GetExtension(resourcesFile));
resourcesFile = t.FilesWritten[0].ItemSpec;
Assert.Equal(".resources", Path.GetExtension(resourcesFile));

Path.GetExtension(t.OutputResources[0].ItemSpec).ShouldBe(".resources");
Path.GetExtension(t.FilesWritten[0].ItemSpec).ShouldBe(".resources");

Utilities.AssertStateFileWasWritten(t);

GenerateResource t2 = Utilities.CreateTask(_output);
GenerateResource t2 = Utilities.CreateTask(_output, usePreserialized, _env);
t2.StateFile = new TaskItem(t.StateFile);
t2.Sources = new ITaskItem[] { new TaskItem(resxFile) };

DateTime time = File.GetLastWriteTime(t.OutputResources[0].ItemSpec);
DateTime firstWriteTime = File.GetLastWriteTime(t.OutputResources[0].ItemSpec);
System.Threading.Thread.Sleep(200);
File.SetLastWriteTime(bitmap, DateTime.Now);
File.SetLastWriteTime(bitmap, DateTime.Now + TimeSpan.FromSeconds(2));

Utilities.ExecuteTask(t2);

Assert.True(DateTime.Compare(File.GetLastWriteTime(t2.OutputResources[0].ItemSpec), time) > 0);
File.GetLastWriteTime(t2.OutputResources[0].ItemSpec).ShouldBeGreaterThan(firstWriteTime);

// ToUpper because WriteTestResX uppercases links
Utilities.AssertLogContainsResource(t2, "GenerateResource.LinkedInputNewer", bitmap.ToUpper(), t2.OutputResources[0].ItemSpec);
Utilities.AssertLogContainsResource(
t2,
"GenerateResource.LinkedInputNewer",
// ToUpper because WriteTestResX uppercases links
NativeMethodsShared.IsWindows ? bitmap.ToUpper() : bitmap,
t2.OutputResources[0].ItemSpec);
}
finally
{
Expand All @@ -419,42 +423,44 @@ public void ForceOutOfDateLinked()
}
}

#if FEATURE_LINKED_RESOURCES
[Fact]
#else
[Fact(Skip = "https://github.com/Microsoft/msbuild/issues/1247")]
#endif
public void ForceOutOfDateLinkedByDeletion()
[Theory]
[MemberData(nameof(Utilities.UsePreserializedResourceStates), MemberType = typeof(Utilities))]
public void ForceOutOfDateLinkedByDeletion(bool usePreserialized)
{
string bitmap = Utilities.CreateWorldsSmallestBitmap();
string resxFile = Utilities.WriteTestResX(false, bitmap, null, false);

GenerateResource t = Utilities.CreateTask(_output);
GenerateResource t = Utilities.CreateTask(_output, usePreserialized, _env);
t.StateFile = new TaskItem(Utilities.GetTempFileName(".cache"));

t.UsePreserializedResources = usePreserialized;

try
{
t.Sources = new ITaskItem[] { new TaskItem(resxFile) };

Utilities.ExecuteTask(t);

string resourcesFile = t.OutputResources[0].ItemSpec;
Path.GetExtension(resourcesFile).ShouldBe(".resources");
resourcesFile = t.FilesWritten[0].ItemSpec;
Path.GetExtension(resourcesFile).ShouldBe(".resources");

Path.GetExtension(t.OutputResources[0].ItemSpec).ShouldBe(".resources");
Path.GetExtension(t.FilesWritten[0].ItemSpec).ShouldBe(".resources");

Utilities.AssertStateFileWasWritten(t);

GenerateResource t2 = Utilities.CreateTask(_output);
GenerateResource t2 = Utilities.CreateTask(_output, usePreserialized, _env);
t2.StateFile = new TaskItem(t.StateFile);
t2.Sources = new ITaskItem[] { new TaskItem(resxFile) };
t2.UsePreserializedResources = usePreserialized;

File.Delete(bitmap);

t2.Execute().ShouldBeFalse();

// ToUpper because WriteTestResX uppercases links
Utilities.AssertLogContainsResource(t2, "GenerateResource.LinkedInputDoesntExist", bitmap.ToUpper());
Utilities.AssertLogContainsResource(
t2,
"GenerateResource.LinkedInputDoesntExist",
// ToUpper because WriteTestResX uppercases links
NativeMethodsShared.IsWindows ? bitmap.ToUpper() : bitmap);
}
finally
{
Expand Down Expand Up @@ -531,19 +537,18 @@ public void ForceSomeOutOfDate()
/// <summary>
/// Allow ShouldRebuildResgenOutputFile to return "false" since nothing's out of date, including linked file
/// </summary>
#if FEATURE_RESX_RESOURCE_READER
[Fact]
#else
[Fact(Skip = "https://github.com/Microsoft/msbuild/issues/1247")]
#endif
public void AllowLinkedNoGenerate()
[Theory]
[MemberData(nameof(Utilities.UsePreserializedResourceStates), MemberType = typeof(Utilities))]
public void AllowLinkedNoGenerate(bool usePreserialized)
{
string bitmap = Utilities.CreateWorldsSmallestBitmap();
string resxFile = Utilities.WriteTestResX(false, bitmap, null, false);

GenerateResource t = Utilities.CreateTask(_output);
GenerateResource t = Utilities.CreateTask(_output, usePreserialized, _env);
t.StateFile = new TaskItem(Utilities.GetTempFileName(".cache"));

t.UsePreserializedResources = usePreserialized;

try
{
t.Sources = new ITaskItem[] { new TaskItem(resxFile) };
Expand All @@ -559,7 +564,7 @@ public void AllowLinkedNoGenerate()

DateTime time = File.GetLastWriteTime(t.OutputResources[0].ItemSpec);

GenerateResource t2 = Utilities.CreateTask(_output);
GenerateResource t2 = Utilities.CreateTask(_output, usePreserialized, _env);
t2.StateFile = new TaskItem(t.StateFile);
t2.Sources = new ITaskItem[] { new TaskItem(resxFile) };

Expand Down Expand Up @@ -2591,9 +2596,8 @@ public References(ITestOutputHelper output)
}

[Fact]
[Trait("Category", "netcore-osx-failing")]
[Trait("Category", "netcore-linux-failing")] // https://github.com/Microsoft/msbuild/issues/309
[Trait("Category", "mono-osx-failing")] // https://github.com/Microsoft/msbuild/issues/677
[SkipOnTargetFramework(TargetFrameworkMonikers.Netcoreapp, "Linked resources not supported on Core: https://github.com/microsoft/msbuild/issues/4094")]
[SkipOnTargetFramework(TargetFrameworkMonikers.Mono, "https://github.com/Microsoft/msbuild/issues/677")]
public void DontLockP2PReferenceWhenResolvingSystemTypes()
{
// This WriteLine is a hack. On a slow machine, the Tasks unittest fails because remoting
Expand Down Expand Up @@ -2769,9 +2773,8 @@ public class Class1
/// Assembly.LoadFrom instead.
/// </summary>
[Fact]
[Trait("Category", "netcore-osx-failing")]
[Trait("Category", "netcore-linux-failing")] // https://github.com/Microsoft/msbuild/issues/309
[Trait("Category", "mono-osx-failing")] // https://github.com/Microsoft/msbuild/issues/677
[SkipOnTargetFramework(TargetFrameworkMonikers.Netcoreapp, "Linked resources not supported on Core: https://github.com/microsoft/msbuild/issues/4094")]
[SkipOnTargetFramework(TargetFrameworkMonikers.Mono, "https://github.com/Microsoft/msbuild/issues/677")]
public void ReferencedAssemblySpecifiedUsingRelativePath()
{
// This WriteLine is a hack. On a slow machine, the Tasks unittest fails because remoting
Expand Down Expand Up @@ -3379,7 +3382,7 @@ public static void ExecuteTask(GenerateResource t)
/// This method creates a GenerateResource task and performs basic setup on it, e.g. BuildEngine
/// </summary>
/// <param name="output"></param>
public static GenerateResource CreateTask(ITestOutputHelper output)
public static GenerateResource CreateTask(ITestOutputHelper output, bool usePreserialized = false, TestEnvironment env = null)
{
// always use the internal ctor that says don't perform separate app domain check
GenerateResource t = new GenerateResource();
Expand All @@ -3388,6 +3391,27 @@ public static GenerateResource CreateTask(ITestOutputHelper output)
// Make the task execute in-proc
t.ExecuteAsTool = false;

if (usePreserialized)
{
t.UsePreserializedResources = usePreserialized;

// Synthesize a reference that looks close enough to System.Resources.Extensions
// to pass the "is it ok to use preserialized resources?" check

var folder = env.CreateFolder(true);
var dll = folder.CreateFile("System.Resource.Extensions.dll");

// Make sure the reference looks old relative to all the other inputs
File.SetLastWriteTime(dll.Path, DateTime.Now - TimeSpan.FromDays(30));

var referenceItem = new TaskItem(dll.Path);
referenceItem.SetMetadata(Tasks.ItemMetadataNames.fusionName, "System.Resources.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51");

t.References = new ITaskItem[] {
referenceItem
};
}

return t;
}

Expand Down Expand Up @@ -3752,6 +3776,17 @@ public static void STRNamespaceTestHelper(string strLanguage, string resourcesNa
}
}
}

public static IEnumerable<object[]> UsePreserializedResourceStates()
{
// All MSBuilds should be able to use the new resource codepaths
yield return new object[] { true };

#if FEATURE_RESX_RESOURCE_READER
// But the old get-live-objects codepath is supported only on full framework.
yield return new object[] { false };
#endif
}
}

/// <summary>
Expand Down
Loading