Esempio n. 1
0
        private IEnumerable <string> GetAllowedPackageReferenceVersions(PackageReference packageReference)
        {
            // If this is a generator project, if it has a reference to Microsoft.CodeAnalysis.Common, that means it's
            // a source generator. In that case, we require the version of the API being built against to match the toolset
            // version, so that way the source generator can actually be loaded by the toolset. We don't apply this rule to
            // any other project, as any other project having a reason to reference a version of Roslyn via a PackageReference
            // probably doesn't fall under this rule.
            if (ProjectFilePath.Contains("CompilerGeneratorTools") && packageReference.Name == "Microsoft.CodeAnalysis.Common")
            {
                yield return("$(SourceGeneratorMicrosoftCodeAnalysisVersion)");
            }
            else
            {
                var name = packageReference.Name.Replace(".", "").Replace("-", "");
                yield return($"$({name}Version)");

                yield return($"$({name}FixedVersion)");
            }
        }
 static bool IsAllowedFloatingVersion(PackageReference packageReference, string projectFilePath)
 => packageReference.Name == "Microsoft.Build.Framework" &&
 Path.GetFileName(projectFilePath) == "Microsoft.CodeAnalysis.Workspaces.MSBuild.csproj";