Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

APICompat is showing noisy diffs where it shouldn't (regarding Parameter Modifiers) #2136

Closed
ahsonkhan opened this issue Feb 28, 2019 · 2 comments
Labels
area-Infrastructure-libraries Area maintained by .NET libraries team: APICompat, AsmDiff, GenAPI, GenFacades, PkgProj, etc

Comments

@ahsonkhan
Copy link
Member

ahsonkhan commented Feb 28, 2019

These two netfx dlls are showing up in ApiCompat runs even when they are identical:

  • Microsoft.VisualC.STLCLR.dll
  • System.Printing.dll

The diffs themselves are all around ParameterModifiersCannotChange and seem non-actionable anyway:

netfx
Compat issues with assembly Microsoft.VisualC.STLCLR:
ParameterModifiersCannotChange : Custom modifiers on parameter '_Right' on method 'Microsoft.VisualC.StlClr.GenericPair<TValue1, TValue2>..ctor(Microsoft.VisualC.StlClr.GenericPair<TValue1, TValue2>)' are 'System.Runtime.CompilerServices.IsImplicitlyDereferenced' in the implementation but 'System.Runtime.CompilerServices.IsImplicitlyDereferenced' in the contract.
ParameterModifiersCannotChange : Custom modifiers on parameter '_Right' on method 'Microsoft.VisualC.StlClr.GenericPair<TValue1, TValue2>.op_Assign(Microsoft.VisualC.StlClr.GenericPair<TValue1, TValue2>)' are 'System.Runtime.CompilerServices.IsImplicitlyDereferenced' in the implementation but 'System.Runtime.CompilerServices.IsImplicitlyDereferenced' in the contract.
ParameterModifiersCannotChange : Custom modifiers on parameter '_Right' on method 'Microsoft.VisualC.StlClr.GenericPair<TValue1, TValue2>.swap(Microsoft.VisualC.StlClr.GenericPair<TValue1, TValue2>)' are 'System.Runtime.CompilerServices.IsImplicitlyDereferenced' in the implementation but 'System.Runtime.CompilerServices.IsImplicitlyDereferenced' in the contract.
ParameterModifiersCannotChange : Custom modifiers on parameter '_Where' on method 'Microsoft.VisualC.StlClr.IDeque<TValue>.erase(Microsoft.VisualC.StlClr.Generic.ContainerRandomAccessIterator<TValue>, 
...
Compat issues with assembly System.Printing:
ParameterModifiersCannotChange : Custom modifiers on parameter 'attribRef' on method 'System.Printing.IndexedProperties.PrintBooleanProperty.op_Implicit(System.Printing.IndexedProperties.PrintBooleanProperty)' are 'System.Runtime.CompilerServices.IsImplicitlyDereferenced' in the implementation but 'System.Runtime.CompilerServices.IsImplicitlyDereferenced' in the contract.
ParameterModifiersCannotChange : Custom modifiers on parameter 'attribRef' on method 'System.Printing.IndexedProperties.PrintByteArrayProperty.op_Implicit(System.Printing.IndexedProperties.PrintByteArrayProperty)' are 'System.Runtime.CompilerServices.IsImplicitlyDereferenced' in the implementation but 'System.Runtime.CompilerServices.IsImplicitlyDereferenced' in the contract.
ParameterModifiersCannotChange : Custom modifiers on parameter 'attribRef' on method 'System.Printing.IndexedProperties.PrintDateTimeProperty.op_Implicit(System.Printing.IndexedProperties.PrintDateTimeProperty)' are 'System.Runtime.CompilerServices.IsImplicitlyDereferenced' in the implementation but 'System.Runtime.CompilerServices.IsImplicitlyDereferenced' in the contract.
ParameterModifiersCannotChange : Custom modifiers on parameter 'attribRef' on method 'System.Printing.IndexedProperties.PrintDriverProperty.op_Implicit(System.Printing.IndexedProperties.PrintDriverProperty)' are 'System.Runtime.CompilerServices.IsImplicitlyDereferenced' in the implementation but 'System.Runtime.CompilerServices.IsImplicitlyDereferenced' in the contract.
...
Total Issues: 151

Comparing all netfx refs corefx\bin\ref\netfx, net45+, ...

See: dotnet/corefx#35557

fc "..\master\bin\ref\netfx\Microsoft.VisualC.STLCLR.dll" "..\branch\bin\ref\netfx\Microsoft.VisualC.STLCLR.dll"
Comparing files ..\MASTER\BIN\REF\NETFX\Microsoft.VisualC.STLCLR.dll and ..\BRANCH\BIN\REF\NETFX\MICROSOFT.VISUALC.STLCLR.DLL
FC: no differences encountered

To reproduce:

  • Build corefx (all configuration, or netfx config)
  • Run APICompat on the bin\ref\netfx folder against itself.
    dotnet "Microsoft.DotNet.ApiCompat.dll" "bin\ref\netfx" -i "bin\ref\netfx"

cc @ericstj

@ericstj
Copy link
Member

ericstj commented Feb 28, 2019

Simple repro:

dotnet c:\Users\ericstj\.nuget\packages\microsoft.dotnet.apicompat\1.0.0-beta.19121.4\tools\netcoreapp2.1\Microsoft.DotNet.ApiCompat.dll "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Printing.dll" -i "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2"

Suspect a bad comparator here:

var union = implParam.CustomModifiers.Union(contractParam.CustomModifiers);
if (implParam.CustomModifiers.Count() != union.Count())
{
differences.AddIncompatibleDifference(this,
$"Custom modifiers on parameter '{implParam.Name.Value}' on method '{implMethod.FullName()}' are '{PrintCustomModifiers(implParam.CustomModifiers)}' in the {Implementation} but '{PrintCustomModifiers(contractParam.CustomModifiers)}' in the {Contract}.");
match = false;
}

Perhaps that's not doing an actual equality check when evaluating the union.

@ericstj
Copy link
Member

ericstj commented Jun 23, 2021

This appears to have been fixed by @dougbu in https://github.com/dotnet/arcade/pull/4585/files#diff-ab264297f1e0d7296c8d69384a224e589d95ced59d203663d968dcc20f7d1e13R68

Note that the error may still appear if ApiCompat is not able to see that the types on both sides are equivalent, so in my repro above it will still fail unless I pass --contract-depends

dotnet c:\Users\erics\.nuget\packages\microsoft.dotnet.apicompat\6.0.0-beta.21281.1\tools\netcoreapp3.1\Microsoft.DotNet.ApiCompat.dll "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Printing.dll" --contract-depends "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2" -i "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2"
Total Issues: 0

@ericstj ericstj closed this as completed Jun 23, 2021
@ericstj ericstj added the area-Infrastructure-libraries Area maintained by .NET libraries team: APICompat, AsmDiff, GenAPI, GenFacades, PkgProj, etc label Mar 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Infrastructure-libraries Area maintained by .NET libraries team: APICompat, AsmDiff, GenAPI, GenFacades, PkgProj, etc
Projects
None yet
Development

No branches or pull requests

2 participants