Skip to content

Commit

Permalink
Update CreateFrameworkListFile to account for new analyzer path forma…
Browse files Browse the repository at this point in the history
…t introduced with dotnet/sdk#20355
  • Loading branch information
eerhardt committed Sep 16, 2021
1 parent 1a30f27 commit 8e772be
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions eng/tools/RepoTasks/CreateFrameworkListFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,19 @@ public override bool Execute()

var pathParts = path.Split('/');

if (pathParts.Length < 3 || !pathParts[1].Equals("dotnet", StringComparison.Ordinal) || pathParts.Length > 4)
if (pathParts.Length < 3 || !pathParts[1].Equals("dotnet", StringComparison.Ordinal) || pathParts.Length > 5)
{
Log.LogError($"Unexpected analyzer path format {path}. Expected 'analyzers/dotnet(/language)/analyzer.dll");
Log.LogError($"Unexpected analyzer path format {path}. Expected 'analyzers/dotnet(/roslyn<version>)(/language)/analyzer.dll");
}

// Check if we have enough parts for language directory and include it
if (pathParts.Length > 3)
// Check if we have enough parts for language directory and include it.
// There could be a roslyn<version> folder before the language folder. Check for it.
bool hasRoslynVersion = pathParts[2].StartsWith("roslyn", StringComparison.Ordinal);
int languageLengthCheck = hasRoslynVersion ? 4 : 3;
int potentialLanguageIndex = hasRoslynVersion ? 3 : 2;
if (pathParts.Length > languageLengthCheck)
{
element.Add(new XAttribute("Language", pathParts[2]));
element.Add(new XAttribute("Language", pathParts[potentialLanguageIndex]));
}
}

Expand Down

0 comments on commit 8e772be

Please sign in to comment.