Skip to content
Merged
Show file tree
Hide file tree
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
@@ -1,10 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
<DefineConstants Condition="'$(ForceValidationProblem)' == 'true'">$(DefineConstants);ForceValidationProblem</DefineConstants>
<DefineConstants Condition="'$(AddBreakingChange)' == 'true'">$(DefineConstants);AddBreakingChange</DefineConstants>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<EnablePackageValidation>true</EnablePackageValidation>
</PropertyGroup>

<ItemGroup>
Expand All @@ -15,8 +16,8 @@
<PackageReference Include="Microsoft.CodeAnalysis" Version="4.0.0-1.21277.15" />
</ItemGroup>

<Import Project="$(MSBuildProjectDirectory)\..\..\..\..\src\Compatibility\Microsoft.DotNet.PackageValidation\build\Microsoft.DotNet.PackageValidation.targets" />
<Import Project="$(MSBuildProjectDirectory)\..\..\..\..\src\Tasks\Microsoft.NET.Build.Tasks\targets\Microsoft.NET.Compatibility.targets" />

<PropertyGroup>
<DotNetPackageValidationAssembly Condition="'$(MSBuildRuntimeType)' != 'Core'">$(MSBuildThisFileDirectory)\bin\$(Configuration)\netstandard2.0\Microsoft.DotNet.PackageValidation.dll</DotNetPackageValidationAssembly>
<DotNetPackageValidationAssembly Condition="'$(MSBuildRuntimeType)' == 'Core'">$(MSBuildThisFileDirectory)\bin\$(Configuration)\net6.0\Microsoft.DotNet.PackageValidation.dll</DotNetPackageValidationAssembly>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System;
using System.Collections.Generic;

namespace Microsoft.DotNet.ApiCompatibility.Abstractions
{
Expand Down Expand Up @@ -29,6 +30,13 @@ public bool Equals(MetadataInformation other) =>
string.Equals(TargetFramework, other.TargetFramework, StringComparison.OrdinalIgnoreCase) &&
string.Equals(AssemblyId, other.AssemblyId, StringComparison.Ordinal);

public override int GetHashCode() => HashCode.Combine(AssemblyName, TargetFramework, AssemblyId);
public override int GetHashCode()
{
int hashCode = 1447485498;
hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(AssemblyName);
hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(TargetFramework);
hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(AssemblyId);
return hashCode;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ public class DiagnosticBag<T> where T : IDiagnostic

public DiagnosticBag(IEnumerable<string> noWarn, (string diagnosticId, string referenceId)[] ignoredDifferences)
{
_noWarn = new HashSet<string>(noWarn);
if (noWarn != null)
_noWarn = new HashSet<string>(noWarn);
else
_noWarn = new HashSet<string>();

_ignore = new Dictionary<string, HashSet<string>>();

if (ignoredDifferences != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#nullable enable
using System;
using System.Collections.Generic;
using System.Xml.Serialization;

namespace Microsoft.DotNet.Compatibility.ErrorSuppression
Expand Down Expand Up @@ -54,6 +55,14 @@ static bool AreEqual(string? first, string? second)
=> string.IsNullOrEmpty(first?.Trim()) && string.IsNullOrEmpty(second?.Trim()) || StringComparer.InvariantCultureIgnoreCase.Equals(first?.Trim(), second?.Trim());
}

public override int GetHashCode() => HashCode.Combine(DiagnosticId?.ToLowerInvariant(), Target?.ToLowerInvariant(), Left?.ToLowerInvariant(), Right?.ToLowerInvariant(), IsBaselineSuppression);
public override int GetHashCode()
{
int hashCode = 1447485498;
hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(DiagnosticId?.ToLowerInvariant() ?? string.Empty);
hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(Target?.ToLowerInvariant() ?? string.Empty);
hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(Left?.ToLowerInvariant() ?? string.Empty);
hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(Right?.ToLowerInvariant() ?? string.Empty);
return hashCode;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Bcl.HashCode" Version="1.1.1" />
<PackageReference Include="Microsoft.CodeAnalysis" Version="$(MicrosoftCodeAnalysisCSharpPackageVersion)" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netcoreapp3.1;net472</TargetFrameworks>
<TargetFrameworks>net6.0;net472</TargetFrameworks>
<IsPackable>true</IsPackable>
<IsShippingPackage>true</IsShippingPackage>
<StrongNameKeyId>Open</StrongNameKeyId>
Expand All @@ -15,10 +15,11 @@
<Compile Include="..\..\Tasks\Common\**\*.cs" LinkBase="Common" />
<PackageReference Include="Microsoft.Build.Framework" Version="$(MicrosoftBuildFrameworkVersion)" ExcludeAssets="Runtime" />
<PackageReference Include="Microsoft.Build.Utilities.Core" Version="$(MicrosoftBuildUtilitiesCoreVersion)" ExcludeAssets="Runtime" />
<PackageReference Include="NuGet.Frameworks" Version="$(NuGetBuildTasksPackageVersion)" />
<PackageReference Include="NuGet.Packaging" Version="$(NuGetBuildTasksPackageVersion)" />
<PackageReference Include="NuGet.Protocol" Version="$(NuGetBuildTasksPackageVersion)" />
<ProjectReference Include="..\Microsoft.DotNet.ApiCompatibility\Microsoft.DotNet.ApiCompatibility.csproj" />
<PackageReference Include="NuGet.Frameworks" Version="$(NuGetBuildTasksPackageVersion)" ExcludeAssets="Runtime" />
<PackageReference Include="NuGet.Packaging" Version="$(NuGetBuildTasksPackageVersion)" ExcludeAssets="Runtime" />
<PackageReference Include="NuGet.Protocol" Version="$(NuGetBuildTasksPackageVersion)" ExcludeAssets="Runtime" />
<PackageReference Include="System.IO.Compression" Version="4.3.0" />
<ProjectReference Include="..\Microsoft.DotNet.ApiCompatibility\Microsoft.DotNet.ApiCompatibility.csproj" ExcludeAssets="Runtime" />
</ItemGroup>

<ItemGroup>
Expand All @@ -34,6 +35,10 @@
<None Include="**/*.props;**/*.targets" Pack="true">
<PackagePath>%(RecursiveDir)%(Filename)%(Extension)</PackagePath>
</None>
<None Include="..\..\Tasks\Microsoft.NET.Build.Tasks\targets\Microsoft.NET.Compatibility.Common.targets" Pack="true" >
<Link>build/Microsoft.NET.Compatibility.Common.targets</Link>
<PackagePath>build/%(Filename)%(Extension)</PackagePath>
</None>
</ItemGroup>

<ItemGroup>
Expand Down Expand Up @@ -81,7 +86,8 @@
<Target Name="_AddBuildOutputToPackageDesktop" Condition="'$(TargetFrameworkIdentifier)' != '.NETCoreApp'">
<ItemGroup>
<!-- Include .NET Framework build outputs in the package under tools directory. -->
<TfmSpecificPackageFile Include="$(OutputPath)**" PackagePath="tools/$(TargetFramework)/%(RecursiveDir)%(FileName)%(Extension)"/>
<TfmSpecificPackageFile Include="$(OutputPath)**"
PackagePath="tools/$(TargetFramework)/%(RecursiveDir)%(FileName)%(Extension)" />
</ItemGroup>
</Target>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,4 +153,7 @@
<data name="Baseline" xml:space="preserve">
<value>[Baseline]</value>
</data>
<data name="UpdateSdkVersion" xml:space="preserve">
<value> The minimum version required of Roslyn is '{1}' and you are using '{0}' version of the Roslyn. You can update the sdk to get the latest version.</value>
</data>
</root>
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System;
using System.IO;
using System.Reflection;
using Microsoft.Build.Framework;
using Microsoft.NET.Build.Tasks;
using NuGet.RuntimeModel;
Expand All @@ -12,6 +15,9 @@ public class ValidatePackage : TaskBase
[Required]
public string PackageTargetPath { get; set; }

[Required]
public string RoslynAssembliesPath { get; set; }

public string RuntimeGraph { get; set; }

public string NoWarn { get; set; }
Expand All @@ -30,6 +36,19 @@ public class ValidatePackage : TaskBase

public string CompatibilitySuppressionFilePath { get; set; }

public override bool Execute()
{
AppDomain.CurrentDomain.AssemblyResolve += ResolverForRoslyn;
try
{
return base.Execute();
}
finally
{
AppDomain.CurrentDomain.AssemblyResolve -= ResolverForRoslyn;
}
}

protected override void ExecuteCore()
{
RuntimeGraph runtimeGraph = null;
Expand All @@ -55,5 +74,21 @@ protected override void ExecuteCore()
logger.GenerateSuppressionsFile(CompatibilitySuppressionFilePath);
}
}

private Assembly ResolverForRoslyn(object sender, ResolveEventArgs args)
{
AssemblyName name = new(args.Name);
if (name.Name == "Microsoft.CodeAnalysis" || name.Name == "Microsoft.CodeAnalysis.CSharp")
{
Assembly asm = Assembly.LoadFrom(Path.Combine(RoslynAssembliesPath, $"{name.Name}.dll"));
Version version = asm.GetName().Version;
if (version < name.Version)
{
throw new Exception(string.Format(Resources.UpdateSdkVersion, version, name.Version));
}
return asm;
}
return null;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,34 +1,10 @@
<!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. -->
<Project>
<UsingTask TaskName="Microsoft.DotNet.PackageValidation.ValidatePackage" AssemblyFile="$(DotNetPackageValidationAssembly)" />
<PropertyGroup>
<DotNetPackageValidationAssembly Condition="'$(MSBuildRuntimeType)' != 'Core'">$(MSBuildThisFileDirectory)..\tools\net472\Microsoft.DotNet.PackageValidation.dll</DotNetPackageValidationAssembly>
<DotNetPackageValidationAssembly Condition="'$(MSBuildRuntimeType)' == 'Core'">$(MSBuildThisFileDirectory)..\tools\net6.0\Microsoft.DotNet.PackageValidation.dll</DotNetPackageValidationAssembly>
<UseCompatibilityPackage>true</UseCompatibilityPackage>
</PropertyGroup>

<ItemGroup Condition="'$(DisablePackageBaselineValidation)' != 'true' and '$(PackageValidationBaselinePath)' == '' and '$(PackageValidationBaselineVersion)' != ''">
<PackageDownload Include="$([MSBuild]::ValueOrDefault('$(PackageValidationBaselineName)', '$(PackageId)'))" Version="[$(PackageValidationBaselineVersion)]" />
</ItemGroup>

<Target Name="RunPackageValidation"
AfterTargets="Pack"
Condition="'$(IsPackable)' == 'true'">

<PropertyGroup>
<PackageValidationBaselineName Condition="'$(PackageValidationBaselineName)' == ''">$(PackageId)</PackageValidationBaselineName>
<PackageValidationBaselinePath Condition="'$(PackageValidationBaselinePath)' == '' and '$(PackageValidationBaselineVersion)' != ''">$([MSBuild]::NormalizePath('$(NuGetPackageRoot)', '$(PackageValidationBaselineName.ToLower())', '$(PackageValidationBaselineVersion)', '$(PackageValidationBaselineName.ToLower()).$(PackageValidationBaselineVersion).nupkg'))</PackageValidationBaselinePath>
<GenerateCompatibilitySuppressionFile Condition="'$(GenerateCompatibilitySuppressionFile)' == ''">false</GenerateCompatibilitySuppressionFile>
<_compatibilitySuppressionFilePath>$([MSBuild]::NormalizePath('$(MSBuildProjectDirectory)', 'CompatibilitySuppressions.xml'))</_compatibilitySuppressionFilePath>
<CompatibilitySuppressionFilePath Condition="'$(CompatibilitySuppressionFilePath)' == '' and (Exists($(_compatibilitySuppressionFilePath)) or '$(GenerateCompatibilitySuppressionFile)' == 'true')">$(_compatibilitySuppressionFilePath)</CompatibilitySuppressionFilePath>
</PropertyGroup>

<!-- PackageTargetPath isn't exposed by NuGet: https://github.com/NuGet/Home/issues/6671. -->
<Microsoft.DotNet.PackageValidation.ValidatePackage
PackageTargetPath="$([MSBuild]::ValueOrDefault('$(PackageTargetPath)', '$([MSBuild]::NormalizePath('$(PackageOutputPath)', '$(PackageId).$(PackageVersion).nupkg'))'))"
RuntimeGraph="$(RuntimeIdentifierGraphPath)"
NoWarn="$(NoWarn)"
RunApiCompat="$([MSBuild]::ValueOrDefault('$(RunApiCompat)', 'true'))"
EnableStrictModeForCompatibleTfms="$([MSBuild]::ValueOrDefault('$(EnableStrictModeForCompatibleTfms)', 'true'))"
EnableStrictModeForCompatibleFrameworksInPackage="$([MSBuild]::ValueOrDefault('$(EnableStrictModeForCompatibleFrameworksInPackage)', 'false'))"
GenerateCompatibilitySuppressionFile="$(GenerateCompatibilitySuppressionFile)"
CompatibilitySuppressionFilePath="$(CompatibilitySuppressionFilePath)"
BaselinePackageTargetPath="$(PackageValidationBaselinePath)"
DisablePackageBaselineValidation="$(DisablePackageBaselineValidation)"/>
</Target>
<Import Project="$(MSBuildThisFileDirectory)Microsoft.NET.Compatibility.Common.targets" />
</Project>

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. -->
<Project>
<Import Project="$(MSBuildThisFileDirectory)..\build\$(MSBuildThisFile)" />
</Project>
</Project>

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@
<target state="new">Package '{0}' not found. Please provide a valid package path.</target>
<note />
</trans-unit>
<trans-unit id="UpdateSdkVersion">
<source> The minimum version required of Roslyn is '{1}' and you are using '{0}' version of the Roslyn. You can update the sdk to get the latest version.</source>
<target state="new"> The minimum version required of Roslyn is '{1}' and you are using '{0}' version of the Roslyn. You can update the sdk to get the latest version.</target>
<note />
</trans-unit>
<trans-unit id="WroteSuppressions">
<source>Successfully wrote compatibility suppressions to '{0}'.</source>
<target state="new">Successfully wrote compatibility suppressions to '{0}'.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@
<target state="new">Package '{0}' not found. Please provide a valid package path.</target>
<note />
</trans-unit>
<trans-unit id="UpdateSdkVersion">
<source> The minimum version required of Roslyn is '{1}' and you are using '{0}' version of the Roslyn. You can update the sdk to get the latest version.</source>
<target state="new"> The minimum version required of Roslyn is '{1}' and you are using '{0}' version of the Roslyn. You can update the sdk to get the latest version.</target>
<note />
</trans-unit>
<trans-unit id="WroteSuppressions">
<source>Successfully wrote compatibility suppressions to '{0}'.</source>
<target state="new">Successfully wrote compatibility suppressions to '{0}'.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@
<target state="new">Package '{0}' not found. Please provide a valid package path.</target>
<note />
</trans-unit>
<trans-unit id="UpdateSdkVersion">
<source> The minimum version required of Roslyn is '{1}' and you are using '{0}' version of the Roslyn. You can update the sdk to get the latest version.</source>
<target state="new"> The minimum version required of Roslyn is '{1}' and you are using '{0}' version of the Roslyn. You can update the sdk to get the latest version.</target>
<note />
</trans-unit>
<trans-unit id="WroteSuppressions">
<source>Successfully wrote compatibility suppressions to '{0}'.</source>
<target state="new">Successfully wrote compatibility suppressions to '{0}'.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@
<target state="new">Package '{0}' not found. Please provide a valid package path.</target>
<note />
</trans-unit>
<trans-unit id="UpdateSdkVersion">
<source> The minimum version required of Roslyn is '{1}' and you are using '{0}' version of the Roslyn. You can update the sdk to get the latest version.</source>
<target state="new"> The minimum version required of Roslyn is '{1}' and you are using '{0}' version of the Roslyn. You can update the sdk to get the latest version.</target>
<note />
</trans-unit>
<trans-unit id="WroteSuppressions">
<source>Successfully wrote compatibility suppressions to '{0}'.</source>
<target state="new">Successfully wrote compatibility suppressions to '{0}'.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@
<target state="new">Package '{0}' not found. Please provide a valid package path.</target>
<note />
</trans-unit>
<trans-unit id="UpdateSdkVersion">
<source> The minimum version required of Roslyn is '{1}' and you are using '{0}' version of the Roslyn. You can update the sdk to get the latest version.</source>
<target state="new"> The minimum version required of Roslyn is '{1}' and you are using '{0}' version of the Roslyn. You can update the sdk to get the latest version.</target>
<note />
</trans-unit>
<trans-unit id="WroteSuppressions">
<source>Successfully wrote compatibility suppressions to '{0}'.</source>
<target state="new">Successfully wrote compatibility suppressions to '{0}'.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@
<target state="new">Package '{0}' not found. Please provide a valid package path.</target>
<note />
</trans-unit>
<trans-unit id="UpdateSdkVersion">
<source> The minimum version required of Roslyn is '{1}' and you are using '{0}' version of the Roslyn. You can update the sdk to get the latest version.</source>
<target state="new"> The minimum version required of Roslyn is '{1}' and you are using '{0}' version of the Roslyn. You can update the sdk to get the latest version.</target>
<note />
</trans-unit>
<trans-unit id="WroteSuppressions">
<source>Successfully wrote compatibility suppressions to '{0}'.</source>
<target state="new">Successfully wrote compatibility suppressions to '{0}'.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@
<target state="new">Package '{0}' not found. Please provide a valid package path.</target>
<note />
</trans-unit>
<trans-unit id="UpdateSdkVersion">
<source> The minimum version required of Roslyn is '{1}' and you are using '{0}' version of the Roslyn. You can update the sdk to get the latest version.</source>
<target state="new"> The minimum version required of Roslyn is '{1}' and you are using '{0}' version of the Roslyn. You can update the sdk to get the latest version.</target>
<note />
</trans-unit>
<trans-unit id="WroteSuppressions">
<source>Successfully wrote compatibility suppressions to '{0}'.</source>
<target state="new">Successfully wrote compatibility suppressions to '{0}'.</target>
Expand Down
Loading