Skip to content

28911 - change Diagnostic.code to 'string | number' - #28959

Closed
Oleksandr Tarasiuk (a-tarasyuk) wants to merge 3 commits into
microsoft:masterfrom
a-tarasyuk:feature/28911-change-diagnostic-code-to-string-or-number
Closed

Oleksandr Tarasiuk (a-tarasyuk) wants to merge 3 commits into
microsoft:masterfrom
a-tarasyuk:feature/28911-change-diagnostic-code-to-string-or-number

Conversation

@a-tarasyuk

Copy link
Copy Markdown
Contributor

Fixes #28911

@ajafff Klaus Meinhardt (ajafff) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should the same change be made to DiagnosticWithLinePosition and DiagnosticRelatedInformation?

@a-tarasyuk

Copy link
Copy Markdown
Contributor Author

Ahmed Jaffery (@ajaff) ok, will add changes to DiagnosticWithLinePosition, DiagnosticRelatedInformation.

@DanielRosenwasser

Daniel Rosenwasser (DanielRosenwasser) commented Dec 12, 2018 •

Copy link
Copy Markdown
Member

The unfortunate thing here is that we're going to cause a few bugs where people create a Set<number | string> and end up using .has on the wrong type. But I think this is fine.

@DanielRosenwasser

Copy link
Copy Markdown
Member

Hey Andrew Casey (@amcasey), can VS handle non-numeric diagnostic codes?

@amcasey

Andrew Casey (amcasey) commented Dec 12, 2018 •

Copy link
Copy Markdown
Member

Daniel Rosenwasser (@DanielRosenwasser), I believe so, but I'll confirm.

Edit: Yes, it can.

@amcasey

Andrew Casey (amcasey) commented Dec 12, 2018 •

Copy link
Copy Markdown
Member

Daniel Rosenwasser (@DanielRosenwasser) I misspoke - Roslyn can accept strings but TS deserializes them as int so old versions of VS will break (probably by dropping these diagnostics).

But we can definitely have newer versions of VS opt into receiving string error codes.

@DanielRosenwasser Daniel Rosenwasser (DanielRosenwasser) added the Breaking Change Would introduce errors in existing code label Dec 13, 2018
@DanielRosenwasser

Daniel Rosenwasser (DanielRosenwasser) commented Dec 13, 2018 •

Copy link
Copy Markdown
Member

Sounds like we'd need to change our API to also support a new configuration option on to say that the client can support string error codes. Even if we decided to add this functionality, we would need to keep numeric error codes around f o r e v e r.

As terrible as it sounds, it might be better to return a new property on Diagnostic objects.

@DanielRosenwasser

Copy link
Copy Markdown
Member

@sheetalkamat

Copy link
Copy Markdown
Member

Daniel Rosenwasser (@DanielRosenwasser) Your suggestion doesnt sound terrible. Infact i like having optional friendlyName property sounds good. That way even we could add the names to error codes (instead of numbers) and editors can decide to use them over number if present to displayed. We should keep errorCode required so that editors not handling the additional optional property can show something that user can search about.

@weswigham

Copy link
Copy Markdown
Member

Friendly human readable short names are good. Although question, if we go there: Can multiple messages share a short name (so, eg, we can group all the excess property variant messages under one "name")? I don't really see why not.

@a-tarasyuk

Copy link
Copy Markdown
Contributor Author

I think this PR has to be closed.

@minestarks

Copy link
Copy Markdown
Contributor

Daniel Rosenwasser (@DanielRosenwasser) just to clarify on #28959 (comment) I feel like a configuration option isn't necessary if we simply add a new optional friendlyName field - errors that support friendly names would always populate the friendlyName and old editors would just ignore it.

@a-tarasyuk
Oleksandr Tarasiuk (a-tarasyuk) deleted the feature/28911-change-diagnostic-code-to-string-or-number branch June 11, 2019 05:14
@microsoft Microsoft (microsoft) locked as resolved and limited conversation to collaborators Oct 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Breaking Change Would introduce errors in existing code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants