Skip to content

Commit

Permalink
Merge branch 'release/7.0.1xx' into release/7.0.2xx
Browse files Browse the repository at this point in the history
  • Loading branch information
v-wuzhai committed Oct 14, 2022
2 parents 860fd2f + 7620a35 commit 40d97cc
Show file tree
Hide file tree
Showing 75 changed files with 1,805 additions and 243 deletions.
12 changes: 6 additions & 6 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@
<Uri>https://github.com/dotnet/aspnetcore</Uri>
<Sha>d50065c4a4fe31a66a1cc2e1a31896d30464da13</Sha>
</Dependency>
<Dependency Name="NuGet.Build.Tasks" Version="6.4.0-preview.3.107">
<Dependency Name="NuGet.Build.Tasks" Version="6.4.0-rc.117">
<Uri>https://github.com/nuget/nuget.client</Uri>
<Sha>1a082949ae5b6da7ca2cce047396c53ae1afdde7</Sha>
<Sha>125f673fd1cdb3cc012f62aa3ce764d2460b89eb</Sha>
</Dependency>
<Dependency Name="Microsoft.NET.Test.Sdk" Version="17.4.0-release-20220926-01">
<Uri>https://github.com/microsoft/vstest</Uri>
Expand Down Expand Up @@ -246,13 +246,13 @@
<Sha>9a1c3e1b7f0c8763d4c96e593961a61a72679a7b</Sha>
<SourceBuild RepoName="xdt" ManagedOnly="true" />
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.NetAnalyzers" Version="7.0.0-preview1.22504.1">
<Dependency Name="Microsoft.CodeAnalysis.NetAnalyzers" Version="7.0.0-preview1.22513.1">
<Uri>https://github.com/dotnet/roslyn-analyzers</Uri>
<Sha>846a766f73caa82608db6fee9f2860004298449f</Sha>
<Sha>ea9fb45000311153bfc91690f306cca2b80e6b83</Sha>
</Dependency>
<Dependency Name="Microsoft.SourceBuild.Intermediate.roslyn-analyzers" Version="3.3.4-beta1.22504.1">
<Dependency Name="Microsoft.SourceBuild.Intermediate.roslyn-analyzers" Version="3.3.4-beta1.22513.1">
<Uri>https://github.com/dotnet/roslyn-analyzers</Uri>
<Sha>846a766f73caa82608db6fee9f2860004298449f</Sha>
<Sha>ea9fb45000311153bfc91690f306cca2b80e6b83</Sha>
<SourceBuild RepoName="roslyn-analyzers" ManagedOnly="true" />
</Dependency>
<Dependency Name="System.CommandLine" Version="2.0.0-beta4.22504.1">
Expand Down
8 changes: 4 additions & 4 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<PreReleaseVersionIteration>
</PreReleaseVersionIteration>
<!-- Enable to remove prerelease label. -->
<StabilizePackageVersion Condition="'$(StabilizePackageVersion)' == ''">false</StabilizePackageVersion>
<StabilizePackageVersion Condition="'$(StabilizePackageVersion)' == ''">true</StabilizePackageVersion>
<DotNetFinalVersionKind Condition="'$(StabilizePackageVersion)' == 'true'">release</DotNetFinalVersionKind>
</PropertyGroup>
<!-- Production Dependencies -->
Expand Down Expand Up @@ -63,7 +63,7 @@
</PropertyGroup>
<PropertyGroup>
<!-- Dependencies from https://github.com/nuget/nuget.client -->
<NuGetBuildTasksPackageVersion>6.4.0-preview.3.107</NuGetBuildTasksPackageVersion>
<NuGetBuildTasksPackageVersion>6.4.0-rc.117</NuGetBuildTasksPackageVersion>
<NuGetBuildTasksConsolePackageVersion>$(NuGetBuildTasksPackageVersion)</NuGetBuildTasksConsolePackageVersion>
<NuGetLocalizationPackageVersion>6.0.0-rc.278</NuGetLocalizationPackageVersion>
<NuGetBuildTasksPackPackageVersion>$(NuGetBuildTasksPackageVersion)</NuGetBuildTasksPackPackageVersion>
Expand Down Expand Up @@ -102,7 +102,7 @@
</PropertyGroup>
<PropertyGroup>
<!-- Dependencies from https://github.com/dotnet/roslyn-analyzers -->
<MicrosoftCodeAnalysisNetAnalyzersVersion>7.0.0-preview1.22504.1</MicrosoftCodeAnalysisNetAnalyzersVersion>
<MicrosoftCodeAnalysisNetAnalyzersVersion>7.0.0-preview1.22513.1</MicrosoftCodeAnalysisNetAnalyzersVersion>
</PropertyGroup>
<PropertyGroup>
<!-- Dependencies from https://github.com/Microsoft/msbuild -->
Expand All @@ -112,7 +112,7 @@
so target one that matches the version in minimumMSBuildVersion.
This avoids the need to juggle references to packages that have been updated in newer MSBuild. -->
<MicrosoftBuildPackageVersion Condition="exists('$(RepoRoot)\src\Layout\redist\minimumMSBuildVersion')">$([System.IO.File]::ReadAllText('$(RepoRoot)\src\Layout\redist\minimumMSBuildVersion').Trim())</MicrosoftBuildPackageVersion>
<MicrosoftBuildPackageVersion Condition="exists('$(RepoRoot)\src\Layout\redist\minimumMSBuildVersion') and '$(DotNetBuildFromSource)' != 'true'">$([System.IO.File]::ReadAllText('$(RepoRoot)\src\Layout\redist\minimumMSBuildVersion').Trim())</MicrosoftBuildPackageVersion>
<MicrosoftBuildFrameworkPackageVersion>$(MicrosoftBuildPackageVersion)</MicrosoftBuildFrameworkPackageVersion>
<MicrosoftBuildRuntimePackageVersion>$(MicrosoftBuildPackageVersion)</MicrosoftBuildRuntimePackageVersion>
<MicrosoftBuildLocalizationPackageVersion>17.5.0-preview-22513-03</MicrosoftBuildLocalizationPackageVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ public static class DiagnosticIds
public const string CannotAddAttribute = "CP0016";
public const string CannotChangeParameterName = "CP0017";
public const string CannotAddSealedToInterfaceMember = "CP0018";
public const string CannotReduceVisibility = "CP0019";
public const string CannotExpandVisibility = "CP0020";

// Assembly loading ids
public const string AssemblyNotFound = "CP1001";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,4 +240,10 @@
<data name="CannotAddSealedToInterfaceMember" xml:space="preserve">
<value>Cannot add sealed keyword to default interface member '{0}'.</value>
</data>
<data name="CannotExpandVisibility" xml:space="preserve">
<value>Visibility of '{0}' expanded from '{1}' to '{2}'.</value>
</data>
<data name="CannotReduceVisibility" xml:space="preserve">
<value>Visibility of '{0}' reduced from '{1}' to '{2}'.</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ private void AddDifference(IList<CompatDifference> differences, DifferenceType d
return;
}

if (!_settings.StrictMode && dt == DifferenceType.Added)
{
return;
}

CompatDifference difference = dt switch
{
DifferenceType.Changed => new CompatDifference(
Expand Down Expand Up @@ -167,10 +172,17 @@ private void ReportAttributeDifferences(ISymbol containing,

for (int i = 0; i < rightGroup.Attributes.Count; i++)
{
if (!rightGroup.Seen[i])
if (!rightGroup.Seen[i] && _settings.StrictMode)
{
// Attribute arguments exist on right but not left.
// Issue "changed" diagnostic.
// Left
// [Foo("a")]
// void F()
// Right
// [Foo("a")]
// [Foo("b")]
// void F()
// Issue "changed" diagnostic when in strict mode.
AddDifference(differences, DifferenceType.Changed, leftMetadata, rightMetadata, containing, itemRef, rightGroup.Attributes[i]);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Collections.Generic;
using Microsoft.CodeAnalysis;
using Microsoft.DotNet.ApiCompatibility.Abstractions;
using Microsoft.DotNet.ApiCompatibility.Extensions;

namespace Microsoft.DotNet.ApiCompatibility.Rules
{
Expand Down Expand Up @@ -50,6 +51,12 @@ private void RunOnMemberSymbol(ISymbol? left, ISymbol? right, ITypeSymbol leftCo

if (left.IsVirtual)
{
// Removing the virtual keyword from a member in a sealed type won't be a breaking change.
if (leftContainingType.IsEffectivelySealed(_settings.IncludeInternalSymbols))
{
return;
}

// If left is virtual and right is not, then emit a diagnostic
// specifying that the virtual modifier cannot be removed.
if (!right.IsVirtual)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
// 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.Collections.Generic;
using System.Runtime;
using Microsoft.CodeAnalysis;
using Microsoft.DotNet.ApiCompatibility.Abstractions;
using Microsoft.DotNet.ApiCompatibility.Extensions;

namespace Microsoft.DotNet.ApiCompatibility.Rules
{
/// <summary>
/// This class implements a rule to check that the visibility of symbols is not reduced.
/// In strict mode, it also checks that the visibility isn't expanded.
/// </summary>
public class CannotChangeVisibility : IRule
{
private readonly RuleSettings _settings;

public CannotChangeVisibility(RuleSettings settings, IRuleRegistrationContext context)
{
_settings = settings;
context.RegisterOnMemberSymbolAction(RunOnMemberSymbol);
context.RegisterOnTypeSymbolAction(RunOnTypeSymbol);
}

private static Accessibility NormalizeInternals(Accessibility a) => a switch
{
Accessibility.ProtectedOrInternal => Accessibility.Protected,
Accessibility.ProtectedAndInternal or Accessibility.Internal => Accessibility.Private,
_ => a,
};

private int CompareAccessibility(Accessibility a, Accessibility b)
{
if (!_settings.IncludeInternalSymbols)
{
a = NormalizeInternals(a);
b = NormalizeInternals(b);
}

if (a == b)
{
return 0;
}

return (a, b) switch
{
(Accessibility.Public, _) => 1,
(_, Accessibility.Public) => -1,
(Accessibility.ProtectedOrInternal, _) => 1,
(_, Accessibility.ProtectedOrInternal) => -1,
(Accessibility.Protected or Accessibility.Internal, _) => 1,
(_, Accessibility.Protected or Accessibility.Internal) => -1,
(Accessibility.ProtectedAndInternal, _) => 1,
(_, Accessibility.ProtectedAndInternal) => -1,
_ => throw new NotImplementedException(),
};
}

private void RunOnSymbol(
ISymbol? left,
ISymbol? right,
MetadataInformation leftMetadata,
MetadataInformation rightMetadata,
IList<CompatDifference> differences)
{
// The MemberMustExist rule handles missing symbols and therefore this rule only runs when left and right is not null.
if (left is null || right is null)
{
return;
}

Accessibility leftAccess = left.DeclaredAccessibility;
Accessibility rightAccess = right.DeclaredAccessibility;
int accessComparison = CompareAccessibility(leftAccess, rightAccess);

if (accessComparison > 0)
{
differences.Add(new CompatDifference(leftMetadata,
rightMetadata,
DiagnosticIds.CannotReduceVisibility,
string.Format(Resources.CannotReduceVisibility, left, leftAccess, rightAccess),
DifferenceType.Changed,
left));
}
else if (_settings.StrictMode && accessComparison < 0)
{
differences.Add(new CompatDifference(leftMetadata,
rightMetadata,
DiagnosticIds.CannotExpandVisibility,
string.Format(Resources.CannotExpandVisibility, right, leftAccess, rightAccess),
DifferenceType.Changed,
right));
}
}

private void RunOnTypeSymbol(
ITypeSymbol? left,
ITypeSymbol? right,
MetadataInformation leftMetadata,
MetadataInformation rightMetadata,
IList<CompatDifference> differences) => RunOnSymbol(left, right, leftMetadata, rightMetadata, differences);

private void RunOnMemberSymbol(
ISymbol? left,
ISymbol? right,
ITypeSymbol leftContainingType,
ITypeSymbol rightContainingType,
MetadataInformation leftMetadata,
MetadataInformation rightMetadata,
IList<CompatDifference> differences) => RunOnSymbol(left, right, leftMetadata, rightMetadata, differences);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ public IRule[] CreateRules(RuleSettings settings, IRuleRegistrationContext conte
new CannotRemoveBaseTypeOrInterface(settings, context),
new CannotSealType(settings, context),
new EnumsMustMatch(settings, context),
new MembersMustExist(settings, context)
new MembersMustExist(settings, context),
new CannotChangeVisibility(settings, context)
};

if (_enableRuleAttributesMustMatch)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,16 @@
<target state="translated">Název parametru u člena {0} se změnil z {1} na {2}.</target>
<note />
</trans-unit>
<trans-unit id="CannotExpandVisibility">
<source>Visibility of '{0}' expanded from '{1}' to '{2}'.</source>
<target state="new">Visibility of '{0}' expanded from '{1}' to '{2}'.</target>
<note />
</trans-unit>
<trans-unit id="CannotReduceVisibility">
<source>Visibility of '{0}' reduced from '{1}' to '{2}'.</source>
<target state="new">Visibility of '{0}' reduced from '{1}' to '{2}'.</target>
<note />
</trans-unit>
<trans-unit id="CannotRemoveAttribute">
<source>Cannot remove attribute '{0}' from '{1}'.</source>
<target state="translated">Atribut {0} nelze odebrat z {1}.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,16 @@
<target state="translated">Der Parametername des Members "{0}" wurde von "{1}" in "{2}" geändert.</target>
<note />
</trans-unit>
<trans-unit id="CannotExpandVisibility">
<source>Visibility of '{0}' expanded from '{1}' to '{2}'.</source>
<target state="new">Visibility of '{0}' expanded from '{1}' to '{2}'.</target>
<note />
</trans-unit>
<trans-unit id="CannotReduceVisibility">
<source>Visibility of '{0}' reduced from '{1}' to '{2}'.</source>
<target state="new">Visibility of '{0}' reduced from '{1}' to '{2}'.</target>
<note />
</trans-unit>
<trans-unit id="CannotRemoveAttribute">
<source>Cannot remove attribute '{0}' from '{1}'.</source>
<target state="translated">Das Attribut "{0}" kann nicht aus "{1}" entfernt werden.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,16 @@
<target state="translated">El nombre de parámetro del miembro '{0}' cambió de '{1}' a '{2}'.</target>
<note />
</trans-unit>
<trans-unit id="CannotExpandVisibility">
<source>Visibility of '{0}' expanded from '{1}' to '{2}'.</source>
<target state="new">Visibility of '{0}' expanded from '{1}' to '{2}'.</target>
<note />
</trans-unit>
<trans-unit id="CannotReduceVisibility">
<source>Visibility of '{0}' reduced from '{1}' to '{2}'.</source>
<target state="new">Visibility of '{0}' reduced from '{1}' to '{2}'.</target>
<note />
</trans-unit>
<trans-unit id="CannotRemoveAttribute">
<source>Cannot remove attribute '{0}' from '{1}'.</source>
<target state="translated">No se puede quitar el atributo '{0}' de '{1}'.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,16 @@
<target state="translated">Le nom du paramètre sur le membre « {0} » est passé de « {1} » à « {2} ».</target>
<note />
</trans-unit>
<trans-unit id="CannotExpandVisibility">
<source>Visibility of '{0}' expanded from '{1}' to '{2}'.</source>
<target state="new">Visibility of '{0}' expanded from '{1}' to '{2}'.</target>
<note />
</trans-unit>
<trans-unit id="CannotReduceVisibility">
<source>Visibility of '{0}' reduced from '{1}' to '{2}'.</source>
<target state="new">Visibility of '{0}' reduced from '{1}' to '{2}'.</target>
<note />
</trans-unit>
<trans-unit id="CannotRemoveAttribute">
<source>Cannot remove attribute '{0}' from '{1}'.</source>
<target state="translated">Impossible de supprimer l’attribut « {0} » de « {1} ».</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,16 @@
<target state="translated">Il nome del parametro nel membro '{0}' è stato modificato da '{1}' a '{2}'.</target>
<note />
</trans-unit>
<trans-unit id="CannotExpandVisibility">
<source>Visibility of '{0}' expanded from '{1}' to '{2}'.</source>
<target state="new">Visibility of '{0}' expanded from '{1}' to '{2}'.</target>
<note />
</trans-unit>
<trans-unit id="CannotReduceVisibility">
<source>Visibility of '{0}' reduced from '{1}' to '{2}'.</source>
<target state="new">Visibility of '{0}' reduced from '{1}' to '{2}'.</target>
<note />
</trans-unit>
<trans-unit id="CannotRemoveAttribute">
<source>Cannot remove attribute '{0}' from '{1}'.</source>
<target state="translated">Non è possibile rimuovere l'attributo '{0}' da '{1}'.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,16 @@
<target state="translated">メンバー '{0}' のパラメーター名が '{1}' から '{2}' に変更されました。</target>
<note />
</trans-unit>
<trans-unit id="CannotExpandVisibility">
<source>Visibility of '{0}' expanded from '{1}' to '{2}'.</source>
<target state="new">Visibility of '{0}' expanded from '{1}' to '{2}'.</target>
<note />
</trans-unit>
<trans-unit id="CannotReduceVisibility">
<source>Visibility of '{0}' reduced from '{1}' to '{2}'.</source>
<target state="new">Visibility of '{0}' reduced from '{1}' to '{2}'.</target>
<note />
</trans-unit>
<trans-unit id="CannotRemoveAttribute">
<source>Cannot remove attribute '{0}' from '{1}'.</source>
<target state="translated">属性 '{0}' を '{1}' から削除できません。</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,16 @@
<target state="translated">멤버 '{0}'의 매개 변수 이름이 '{1}'에서 '{2}'(으)로 변경되었습니다.</target>
<note />
</trans-unit>
<trans-unit id="CannotExpandVisibility">
<source>Visibility of '{0}' expanded from '{1}' to '{2}'.</source>
<target state="new">Visibility of '{0}' expanded from '{1}' to '{2}'.</target>
<note />
</trans-unit>
<trans-unit id="CannotReduceVisibility">
<source>Visibility of '{0}' reduced from '{1}' to '{2}'.</source>
<target state="new">Visibility of '{0}' reduced from '{1}' to '{2}'.</target>
<note />
</trans-unit>
<trans-unit id="CannotRemoveAttribute">
<source>Cannot remove attribute '{0}' from '{1}'.</source>
<target state="translated">'{1}'에서 특성 '{0}'을(를) 제거할 수 없습니다.</target>
Expand Down
Loading

0 comments on commit 40d97cc

Please sign in to comment.