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

Fix inconsistency bug, child cannot widen as support, can narrow #4208

Merged
merged 2 commits into from
Sep 24, 2020

Conversation

buyaa-n
Copy link
Member

@buyaa-n buyaa-n commented Sep 23, 2020

Fixes #4168

Besides fixing the inconsistency issue this PR is updating out attributes handling logic:

Before: We were collecting all attributes for the invoked member and its containing types, after that were determining attributes inconsistency along with suppression from call site attributes when incosistency occurs bailout to avoid false positives. Also in case lowest version of supported and unsupported attributes are equal that counted as Deny list

Now: We are checking attributes consistency for each level, starting from the Parent, for merging each child member's attributes follow the rule suggested by @terrajobst: child annotations can narrow support, but they cannot widen it, attributes not respecting the rule are ignored. Also in case, the lowest version of supported and unsupported attributes are equal that counted as Allow list.

@codecov
Copy link

codecov bot commented Sep 23, 2020

Codecov Report

Merging #4208 into release/dotnet5-rc2 will increase coverage by 0.01%.
The diff coverage is 98.35%.

@@                   Coverage Diff                   @@
##           release/dotnet5-rc2    #4208      +/-   ##
=======================================================
+ Coverage                95.77%   95.79%   +0.01%     
=======================================================
  Files                     1164     1164              
  Lines                   263407   263723     +316     
  Branches                 15901    15910       +9     
=======================================================
+ Hits                    252271   252626     +355     
+ Misses                    9137     9086      -51     
- Partials                  1999     2011      +12     

Copy link
Member

@terrajobst terrajobst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The description makes sense to me, but I haven't studied the code in detail.

@jeffhandley
Copy link
Member

Description sounds good to me. Code and tests look good, but I'll also appreciate @mavasani's review tomorrow. I'm going to do some local testing before I hit approve.

@jeffhandley
Copy link
Member

My preliminary testing looks good. I specifically tested for the scenarios reported in #4168 as well as some other baseline tests, and they're behaving as expected.

@buyaa-n, you mentioned that this change surfaced some new diagnostics in the dotnet/runtime repo; can you share that list of errors here please?


if (childAttributes != null)
{
if (parentAttributes != null && parentAttributes.Any())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am surprised that the rule doesn't raise but it'd be better to use Count instead of Any().

Copy link
Member Author

@buyaa-n buyaa-n Sep 24, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am actually getting diagnostic to use Any() over Count instead

// if all are deny list then we can add the child attributes
foreach (var (name, childAttribute) in childAttributes)
{
if (parentAttributes.TryGetValue(name, out var existing))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert condition and return to reduce nesting.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not returning here nor in the revert

attributes.SupportedSecond = childAttribute.SupportedFirst;
}

if (childAttribute.UnsupportedFirst != null)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert + return to reduce nesting.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We cannot return on revert, need to continue to the next attribute for other platform

@buyaa-n
Copy link
Member Author

buyaa-n commented Sep 24, 2020

@buyaa-n, you mentioned that this change surfaced some new diagnostics in the dotnet/runtime repo; can you share that list of errors here please?

Sure

D:\dotnet\runtime\src\libraries\System.Net.Sockets\src\System\Net\Sockets\IOControlKeepAlive.Windows.cs(77,66): error CA1416: 'IOControlCode.KeepAliveValues' is supported on 'windows' [D:\dotnet\runtime\src\libraries\System.Net.Sockets\src\System.Net.Sockets.csproj]
D:\dotnet\runtime\src\libraries\System.Net.Sockets\src\System\Net\Sockets\TCPListener.cs(266,16): error CA1416: 'Socket.SetIPProtectionLevel(IPProtectionLevel)' is supported on 'windows' [D:\dotnet\runtime\src\libraries\System.Net.Sockets\src\System.Net.Sockets.csproj]
D:\dotnet\runtime\src\libraries\System.Security.Cryptography.Pkcs\src\Internal\Cryptography\Pal\Windows\PkcsPalWindows.cs(174,21): error CA1416: 'CspParameters.Flags.get' is supported on 'windows' [D:\dotnet\runtime\src\libraries\System.Security.Cryptography.Pkcs\src\System.Security.Cryptography.Pkcs.csproj]
D:\dotnet\runtime\src\libraries\System.Security.Cryptography.Pkcs\src\Internal\Cryptography\Pal\Windows\PkcsPalWindows.cs(180,39): error CA1416: 'DSACryptoServiceProvider' is supported on 'windows' [D:\dotnet\runtime\src\libraries\System.Security.Cryptography.Pkcs\src\System.Security.Cryptography.Pkcs.csproj]
D:\dotnet\runtime\src\libraries\System.Security.Cryptography.Pkcs\src\Internal\Cryptography\Pal\Windows\PkcsPalWindows.cs(169,31): error CA1416: 'CspParameters.Flags.get' is supported on 'windows' [D:\dotnet\runtime\src\libraries\System.Security.Cryptography.Pkcs\src\System.Security.Cryptography.Pkcs.csproj]
D:\dotnet\runtime\src\libraries\System.Security.Cryptography.Pkcs\src\Internal\Cryptography\Pal\Windows\PkcsPalWindows.cs(170,17): error CA1416: 'CspParameters.KeyNumber' is supported on 'windows' [D:\dotnet\runtime\src\libraries\System.Security.Cryptography.Pkcs\src\System.Security.Cryptography.Pkcs.csproj]
D:\dotnet\runtime\src\libraries\System.Security.Cryptography.Pkcs\src\Internal\Cryptography\Pal\Windows\PkcsPalWindows.cs(178,39): error CA1416: 'RSACryptoServiceProvider' is supported on 'windows' [D:\dotnet\runtime\src\libraries\System.Security.Cryptography.Pkcs\src\System.Security.Cryptography.Pkcs.csproj]
D:\dotnet\runtime\src\libraries\System.Security.Cryptography.Pkcs\src\Internal\Cryptography\Pal\Windows\HelpersWindows.cs(419,17): error CA1416: 'CspParameters.ProviderName' is supported on 'windows' [D:\dotnet\runtime\src\libraries\System.Security.Cryptography.Pkcs\src\System.Security.Cryptography.Pkcs.csproj]
D:\dotnet\runtime\src\libraries\System.Security.Cryptography.Pkcs\src\Internal\Cryptography\Pal\Windows\HelpersWindows.cs(415,20): error CA1416: 'CspParameters' is supported on 'windows' [D:\dotnet\runtime\src\libraries\System.Security.Cryptography.Pkcs\src\System.Security.Cryptography.Pkcs.csproj]
D:\dotnet\runtime\src\libraries\System.Security.Cryptography.Pkcs\src\Internal\Cryptography\Pal\Windows\HelpersWindows.cs(417,17): error CA1416: 'CspParameters.Flags.set' is supported on 'windows' [D:\dotnet\runtime\src\libraries\System.Security.Cryptography.Pkcs\src\System.Security.Cryptography.Pkcs.csproj]
D:\dotnet\runtime\src\libraries\System.Security.Cryptography.Pkcs\src\Internal\Cryptography\Pal\Windows\HelpersWindows.cs(418,17): error CA1416: 'CspParameters.KeyContainerName' is supported on 'windows' [D:\dotnet\runtime\src\libraries\System.Security.Cryptography.Pkcs\src\System.Security.Cryptography.Pkcs.csproj]  

@Evangelink
Copy link
Member

I find the error message a little weird: 'IOControlCode.KeepAliveValues' is supported on 'windows', is it supposed to be not supported?

@buyaa-n
Copy link
Member Author

buyaa-n commented Sep 24, 2020

I find the error message a little weird: 'IOControlCode.KeepAliveValues' is supported on 'windows', is it supposed to be not supported?

Not supported would say `'IOControlCode.KeepAliveValues' is unsupported on 'windows'. the above means the API si only supported in windows. We agree that the messaging is not perfect and we have an issue to improve it in the future #4021

@jeffhandley
Copy link
Member

Thanks, @buyaa-n and @mavasani. Those errors match the expectations with this fix. Let's go ahead and merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants