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

IDISP004 vs DataColumn #123

Open
nulltoken opened this issue Oct 25, 2018 · 3 comments
Open

IDISP004 vs DataColumn #123

nulltoken opened this issue Oct 25, 2018 · 3 comments

Comments

@nulltoken
Copy link

This is a little bit similar to #90, in the sense that the Fluent Interfaces comes in the way.

var dataTable = new DataTable()

#pragma warning disable IDISP004 // Don't ignore return value of type IDisposable.
dataTable.Columns.Add("Id", typeof(Guid));
#pragma warning restore IDISP004 // Don't ignore return value of type IDisposable.

// Do rocket science with that dataTable thingie

Relevant (maybe): https://stackoverflow.com/questions/913228/should-i-dispose-dataset-and-datatable

Thoughts? Would that be worthwhile to special case those types?

@JohanLarsson
Copy link
Collaborator

JohanLarsson commented Oct 25, 2018

I say we special case everything in the framework and common nugets. Never hesitate to write issues!
I write very little web and database stuff so this analyzer relies on issues from you guys to handle those APIs in a reasonable way.

Goal is that we should only need pragma when cheating, ambitious goal.

We have a gitter room if you are interested in hanging out and chat. Everyone welcome!

Issues is still the best way to report bugs of course.

@bclothier
Copy link

Just a thought - you could consider using attributes for this, too.

Example:

At assembly level:

[assembly: ExemptIDisposableTypes{typeof(DataTable), typeof(DataColumn)]

At a class level (for user code):

[ExemptIDisposableType]
public class StrangeIDisposableThingie : IDisposable {...}

Not sure if possible to enforce attributes on namespaces. I doubt that, though.

@JohanLarsson
Copy link
Collaborator

JohanLarsson commented Nov 6, 2018

Yes, attributes makes sense. #92
For framework and common nugets we should still have reasonable defaults.

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

No branches or pull requests

3 participants