-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Deprecate API and add NFW telemetry for it #70365
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,8 @@ | |
using Roslyn.Test.Utilities; | ||
using Xunit; | ||
|
||
#pragma warning disable CS0618 // Type or member is obsolete | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jasonmalinowski the presumption here is that we do not actual send NFWs for compiler unit tests. |
||
|
||
namespace Microsoft.CodeAnalysis.CSharp.UnitTests | ||
{ | ||
public class SerializationTests | ||
|
@@ -305,3 +307,5 @@ public class C | |
} | ||
} | ||
} | ||
|
||
#pragma warning restore CS0618 // Type or member is obsolete |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ | |
using System.Linq; | ||
using System.Text; | ||
using System.Threading; | ||
using Microsoft.CodeAnalysis.ErrorReporting; | ||
using Microsoft.CodeAnalysis.Text; | ||
using Roslyn.Utilities; | ||
|
||
|
@@ -1391,6 +1392,7 @@ public bool IsEquivalentTo(SyntaxNode node, bool topLevel = false) | |
/// Serializes the node to the given <paramref name="stream"/>. | ||
/// Leaves the <paramref name="stream"/> open for further writes. | ||
/// </summary> | ||
[Obsolete(SerializationDeprecationException.Text, error: false)] | ||
public virtual void SerializeTo(Stream stream, CancellationToken cancellationToken = default) | ||
{ | ||
if (stream == null) | ||
|
@@ -1403,10 +1405,26 @@ public virtual void SerializeTo(Stream stream, CancellationToken cancellationTok | |
throw new InvalidOperationException(CodeAnalysisResources.TheStreamCannotBeWrittenTo); | ||
} | ||
|
||
// Report NFW to see if this is being used in the wild. | ||
FatalError.ReportAndPropagate(new SerializationDeprecationException()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as other place. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the check that is causing the MVID test to fo fail. |
||
using var writer = new ObjectWriter(stream, leaveOpen: true, cancellationToken); | ||
writer.WriteValue(Green); | ||
} | ||
|
||
/// <summary> | ||
/// Specialized exception subtype to make it easier to search telemetry streams for this specific case. | ||
/// </summary> | ||
private protected sealed class SerializationDeprecationException : Exception | ||
{ | ||
public const string Text = "Syntax serialization support is deprecated and will be removed in a future version of this API"; | ||
|
||
public SerializationDeprecationException() | ||
: base(Text) | ||
{ | ||
|
||
} | ||
} | ||
|
||
#region Core Methods | ||
|
||
/// <summary> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,8 @@ | |
using Microsoft.CodeAnalysis.CSharp.Syntax; | ||
using Microsoft.CodeAnalysis.Text; | ||
|
||
#pragma warning disable CS0618 // Type or member is obsolete | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For these you could also the class itself as [Obsolete] which might make it clearer this obsolete in it's own right. |
||
|
||
namespace IdeCoreBenchmarks | ||
{ | ||
[MemoryDiagnoser] | ||
|
@@ -96,3 +98,5 @@ public void DeserializeSyntaxNode() | |
} | ||
} | ||
} | ||
|
||
#pragma warning restore CS0618 // Type or member is obsolete |
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.
@jasonmalinowski does this look correct wrt to reporting a good NFW we can trak on our side?
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.
I'd use ReportAndCatch; as discussed it doesn't change anything beyond the return code (if it were being used in an exception filter), but this as written might make people think this will actually throw this.
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.
not available at this layer :)