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

Alert to usage of legacy collection types #37

Open
sharwell opened this issue Jan 9, 2015 · 3 comments
Open

Alert to usage of legacy collection types #37

sharwell opened this issue Jan 9, 2015 · 3 comments

Comments

@sharwell
Copy link
Member

sharwell commented Jan 9, 2015

Many "legacy" collection types in the .NET framework do not have the ObsoleteAttribute applied to them. To assist users who want to receive warning messages when these types are used, it would be helpful to have a diagnostic available.

This diagnostic would provide a solution for all parties discussing the matter in dotnet/corefx#384.

@paulomorgado
Copy link

What are you looking for with this diagnostic? Specific types or a pattern?

From the top of my mind, I'd say that any type that implements IEnumerable, ICollection, IList and IDIctionary and doesn't implement their generic counterparts (IEnumerable<T>, ICollection<T>, IList<T> and IDictionary<TKey, TValue>).

@sharwell
Copy link
Member Author

I'm open to suggestions. Also this is fairly low impact for me personally, but someone else more directly affected may want to start an implementation.

@AmadeusW
Copy link

Usually ObsoleteAttribute specifies a recommended method or type. For example System.Uri.MakeRelative:
[ObsoleteAttribute("The method has been deprecated. Please use MakeRelativeUri(Uri uri). http://go.microsoft.com/fwlink/?linkid=14202")]

I considered an analyzer whose fix is to update the obsolete method based on the message.
Figured such fix may fit this discussion.

However, the recommended method is just a string intertwined with the rest of the message, and sometimes the conversion would result in erroneous code due to incompatible types, like in PerformanceCounterCategory.Create.

What are you thoughts on extracting a fully qualified name from the message, or introducing a more systematic way to write the ObsoleteAttribute message?

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

No branches or pull requests

3 participants