Skip to content
Draft
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ public sealed class TestingPlatformSelfRegisteredExtensions : Build.Utilities.Ta
{
private const string DisplayNameMetadataName = "DisplayName";
private const string TypeFullNameMetadataName = "TypeFullName";
private const string WellKnownBuilderHookMicrosoftTestingExtensionsTrx = "2006B3F7-93D2-4D9C-9C69-F41A1F21C9C7";
private const string CSharpLanguageSymbol = "C#";
private const string FSharpLanguageSymbol = "F#";
private const string VBLanguageSymbol = "VB";
Expand Down Expand Up @@ -117,8 +116,6 @@ public override bool Execute()

if (!Log.HasLoggedErrors)
{
ITaskItem[] taskItems = Reorder(SelfRegisteredExtensionsBuilderHook);

if (!Language.ItemSpec.Equals(CSharpLanguageSymbol, StringComparison.OrdinalIgnoreCase) &&
!Language.ItemSpec.Equals(VBLanguageSymbol, StringComparison.OrdinalIgnoreCase) &&
!Language.ItemSpec.Equals(FSharpLanguageSymbol, StringComparison.OrdinalIgnoreCase))
Expand All @@ -128,37 +125,14 @@ public override bool Execute()
}
else
{
GenerateCode(Language.ItemSpec, RootNamespace, taskItems, SelfRegisteredExtensionsSourcePath, _fileSystem, Log);
GenerateCode(Language.ItemSpec, RootNamespace, SelfRegisteredExtensionsBuilderHook, SelfRegisteredExtensionsSourcePath, _fileSystem, Log);
SelfRegisteredExtensionsGeneratedFilePath = SelfRegisteredExtensionsSourcePath;
}
}

return !Log.HasLoggedErrors;
}

private static ITaskItem[] Reorder(ITaskItem[] items)
{
List<ITaskItem> result = [with(items.Length)];
int wellKnownBuilderHook_MicrosoftTestingPlatformExtensions_index = -1;
for (int i = 0; i < items.Length; i++)
{
if (items[i].ItemSpec == WellKnownBuilderHookMicrosoftTestingExtensionsTrx)
{
wellKnownBuilderHook_MicrosoftTestingPlatformExtensions_index = i;
continue;
}

result.Add(items[i]);
}

if (wellKnownBuilderHook_MicrosoftTestingPlatformExtensions_index != -1)
{
result.Add(items[wellKnownBuilderHook_MicrosoftTestingPlatformExtensions_index]);
}

return [.. result];
}

private static void GenerateCode(string language, string? rootNamespace, ITaskItem[] taskItems, ITaskItem testingPlatformEntryPointSourcePath, IFileSystem fileSystem, TaskLoggingHelper taskLoggingHelper)
{
StringBuilder builder = new();
Expand Down