Skip to content

Conversation

@marek-safar
Copy link
Contributor

No description provided.

@ghost ghost assigned marek-safar Apr 4, 2022
@ghost ghost added the area-Meta label Apr 4, 2022
@ghost
Copy link

ghost commented Apr 4, 2022

Tagging subscribers to this area: @dotnet/area-meta
See info in area-owners.md if you want to be subscribed.

Issue Details

null

Author: marek-safar
Assignees: marek-safar
Labels:

area-Meta

Milestone: -

@marek-safar marek-safar force-pushed the ide0060 branch 3 times, most recently from e0e389d to b055821 Compare April 4, 2022 09:11
@stephentoub
Copy link
Member

image

You're killing me, Marek :)

Copy link
Member

@stephentoub stephentoub left a comment

Choose a reason for hiding this comment

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

I skimmed the first half. Can't spend more time on it this moment.

// This method is identical to Type.GetTypeFromCLSID. Since it's interop specific, we expose it
// on Marshal for more consistent API surface.
internal static Type? GetTypeFromCLSID(Guid clsid, string? server, bool throwOnError)
internal static Type? GetTypeFromCLSID(Guid clsid, string? server, bool *throwOnError)
Copy link
Member

Choose a reason for hiding this comment

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

What is this asterisk?

Also, why the suppression rather than removing the parameter?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Bad merge

// This is a fail-fast function used by the runtime as a last resort that will terminate the process with
// as little effort as possible. No guarantee is made about the semantics of this fail-fast.
internal static void FallbackFailFast(RhFailFastReason reason, object unhandledException)
internal static void FallbackFailFast(RhFailFastReason _ /*reason*/, object _1 /*unhandledException*/)
Copy link
Member

Choose a reason for hiding this comment

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

Why change the parameter names? Does the analyzer ignore underscore-prefixed names?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

{
public static partial class ThreadPool
{
[Conditional("unnecessary")]
Copy link
Member

Choose a reason for hiding this comment

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

We should come up with some standard compilation-constant we use in such situations, rather than just "unnecessary".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What value do you suggest ?

[LibraryImport(Libraries.OpenLdap, EntryPoint = "ber_get_stringal")]
private static partial int ber_get_stringal(SafeBerHandle berElement, ref IntPtr value);

#pragma warning disable IDE0060
Copy link
Member

Choose a reason for hiding this comment

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

On the native side of things, we use the equivalent of discards rather than suppressions, e.g.

// V and v are not supported on Unix yet.
_ = berElement;
_ = value;
_ = tag;

Should we standardize on doing the same thing in managed, rather than suppressing IDE0060 (and any other analyzers that might flag the same thing)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure if the compiler will be able to optimize this out in all cases.

[UnsupportedOSPlatform("tvos")]
internal static class ContextFlagsAdapterPal
{
#pragma warning disable IDE0060
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we should instead update IDE0060 to recognize the pattern where the whole body is throw new PNSE(...) and not warn on such methods? The developer obviously doesn't intend to use the method at all in such cases, nevermind its arguments.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That sounds like a reasonable suggestion for analyzer improvement

/// </summary>
/// <param name="ldapHandle">The connection handle to the LDAP server.</param>
/// <param name="flags">Flags that control the interaction used to retrieve any necessary Sasl authentication parameters</param>
/// <param name="_"></param>
Copy link
Member

Choose a reason for hiding this comment

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

This makes the approach of using "_" for unused parameters even stranger.

/// <param name="interactPtr">Pointer to the challenge we need to resolve</param>
/// <returns></returns>
internal static int SaslInteractionProcedure(IntPtr ldapHandle, uint flags, IntPtr defaultsPtr, IntPtr interactPtr)
internal static int SaslInteractionProcedure(IntPtr ldapHandle, uint _, IntPtr defaultsPtr, IntPtr interactPtr)
Copy link
Member

Choose a reason for hiding this comment

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

Other places you used a comment with the parameter name.

#pragma warning disable IDE0060
internal static Task? GetAddrInfoAsync(string hostName, bool justAddresses, AddressFamily family, CancellationToken cancellationToken) =>
throw new NotSupportedException();
#pragma warning restore IDE0060
Copy link
Member

Choose a reason for hiding this comment

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

Another example where fixing IDE0060 to ignore always-throw methods would be beneficial. I don't think there should be controversy about it, but if there is, we could make it an opt-in thing, and we'd opt-in in the editorconfig.

[UnsupportedOSPlatform("tvos")]
internal static partial class NegotiateStreamPal
{
#pragma warning disable IDE0060
Copy link
Member

Choose a reason for hiding this comment

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

In general if there are places where we surround the whole body with disable/restore, I think we should just disable it at the top of the file

int headerSize,
int trailerSize,
int _ /*headerSize*/,
int _1 /*trailerSize*/,
Copy link
Member

Choose a reason for hiding this comment

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

These _, _1, _2, etc. parameters just make the source harder to read, make things harder to understand in IntelliSense, etc. As noted earlier, I'd prefer if we were on a plan to use discards.

@ghost ghost added the no-recent-activity label Apr 23, 2022
@ghost
Copy link

ghost commented Apr 23, 2022

This pull request has been automatically marked no-recent-activity because it has not had any activity for 14 days. It will be closed if no further activity occurs within 14 more days. Any new comment (by anyone, not necessarily the author) will remove no-recent-activity.

@ghost ghost removed the no-recent-activity label Apr 27, 2022
@ghost ghost closed this May 27, 2022
@ghost
Copy link

ghost commented May 27, 2022

Draft Pull Request was automatically closed for 30 days of inactivity. Please let us know if you'd like to reopen it.

@ghost ghost locked as resolved and limited conversation to collaborators Jun 26, 2022
@dotnet dotnet unlocked this conversation Jul 22, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Aug 21, 2022
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants