-
Notifications
You must be signed in to change notification settings - Fork 747
Add per-source telemetry for package IDs containing non-alphanumeric, dash, dot, or underscore characters #7213
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
Open
Copilot
wants to merge
7
commits into
dev
Choose a base branch
from
copilot/add-telemetry-package-id-validation
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
61942fa
Initial plan
Copilot 60ab977
Add HasNonstandardId telemetry for non-standard package ID characters…
Copilot a9de1db
Rename HasNonstandardId to IdContainsNonAsciiCharacter throughout
Copilot e1b0705
Replace Regex with ReadOnlySpan char check in HasNonstandardCharacters
Copilot 79664c2
Add telemetry to RestoreCommand as well
jeffkl b0d3c49
Feedback
jeffkl 5a894ff
Fix nullability annotations in ProtocolDiagnosticNupkgCopiedEvent and…
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 14 additions & 2 deletions
16
src/NuGet.Core/NuGet.Protocol/Events/ProtocolDiagnosticNupkgCopiedEvent.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,21 +1,33 @@ | ||
| // Copyright (c) .NET Foundation. All rights reserved. | ||
| // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
|
||
| #nullable disable | ||
|
|
||
| namespace NuGet.Protocol.Events | ||
| { | ||
| public sealed class ProtocolDiagnosticNupkgCopiedEvent | ||
| { | ||
| public string Source { get; } | ||
| public long FileSize { get; } | ||
|
|
||
| /// <summary> | ||
| /// Gets the package ID of the copied nupkg, or <see langword="null"/> if not available. | ||
| /// </summary> | ||
| public string? PackageId { get; } | ||
|
|
||
| public ProtocolDiagnosticNupkgCopiedEvent( | ||
| string source, | ||
| long fileSize) | ||
| : this(source, fileSize, packageId: null) | ||
| { | ||
| } | ||
|
|
||
| public ProtocolDiagnosticNupkgCopiedEvent( | ||
| string source, | ||
| long fileSize, | ||
| string? packageId) | ||
| { | ||
| Source = source; | ||
| FileSize = fileSize; | ||
| PackageId = packageId; | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
src/NuGet.Core/NuGet.Protocol/PublicAPI/net472/PublicAPI.Unshipped.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,3 @@ | ||
| #nullable enable | ||
| NuGet.Protocol.Events.ProtocolDiagnosticNupkgCopiedEvent.PackageId.get -> string? | ||
| NuGet.Protocol.Events.ProtocolDiagnosticNupkgCopiedEvent.ProtocolDiagnosticNupkgCopiedEvent(string! source, long fileSize, string? packageId) -> void |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
src/NuGet.Core/NuGet.Protocol/PublicAPI/net8.0/PublicAPI.Unshipped.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,3 @@ | ||
| #nullable enable | ||
| NuGet.Protocol.Events.ProtocolDiagnosticNupkgCopiedEvent.PackageId.get -> string? | ||
| NuGet.Protocol.Events.ProtocolDiagnosticNupkgCopiedEvent.ProtocolDiagnosticNupkgCopiedEvent(string! source, long fileSize, string? packageId) -> void |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jeffkl This can be non null if we force copilot to just "break" the API potentially.
We can also just force is to annotate as non-null on purpose and annotate the old constructor as null and default the package ID to string.Empty?
I tend to prefer non-null whenever possible so I'm fine with the breaking change.
cc @zivkan
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Plus "ProtocolDiagnostics" were always intended to be used by our telemetry. Since we refuse to use
InternalsVisibleTofor anything other than tests, we have no technical means to make it internal to NuGet across product assembly boundaries. But for this reason, I'm much less concerned about breaking changes in ProtocolDiagnostics than I am about any other API.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has been a sanity policy that tends to work super well as a general rule.
That being said, exposing InternalsVisibileTo to projects that never ship as packages, probably won't break anything.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem is that InternalsVisibleTo doesn't allow you to limit it to just ProtocolDiagnostics or a limited list of types. It makes every
internalmodifier available. And when using Intellisense or similar from that target assembly, giving you a list of available types and autocomplete, you won't know if the NuGet.Protocol type is internal or public, making it too easy to use types that we really don't want to be used outside NuGet.Protocol. So, I don't like the idea of using InternalsVisibleTo some of our VS assembles.