-
Notifications
You must be signed in to change notification settings - Fork 26
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
IDisposableAnnotations #130
base: master
Are you sure you want to change the base?
Changes from 1 commit
db643f5
c5ee579
a11f84c
3d3249e
e0030f4
042c52d
00fb549
28ab920
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFramework>netstandard1.0</TargetFramework> | ||
</PropertyGroup> | ||
</Project> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
namespace DisposableAnnotations | ||
{ | ||
using System; | ||
|
||
/// <summary> | ||
/// The return value should be disposed by caller. | ||
/// </summary> | ||
[AttributeUsage(AttributeTargets.ReturnValue, AllowMultiple = false, Inherited = true)] | ||
public class DisposeAttribute : Attribute | ||
{ | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
namespace DisposableAnnotations | ||
{ | ||
using System; | ||
|
||
/// <summary> | ||
/// The containing method owns the instance and is responsible for disposing it. | ||
/// </summary> | ||
[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = true)] | ||
public class DisposesAttribute : Attribute | ||
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. To come up with an alternative for the sake of discussion:
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. I think we need to make it a verb to be more explicit for the callers. |
||
{ | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
namespace DisposableAnnotations | ||
{ | ||
using System; | ||
|
||
/// <summary> | ||
/// The return value should not be disposed by caller. | ||
/// </summary> | ||
[AttributeUsage(AttributeTargets.ReturnValue, AllowMultiple = false, Inherited = true)] | ||
public class DontDisposeAttribute : Attribute | ||
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. I don't like the contraction. |
||
{ | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
namespace ValidCode | ||
{ | ||
using System; | ||
using DisposableAnnotations; | ||
|
||
public interface IWithAnnotations | ||
{ | ||
[return:Dispose] | ||
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.
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. Agree. Would |
||
IDisposable Create(); | ||
|
||
[return: DontDispose] | ||
IDisposable GetOrCreate(); | ||
|
||
void Add([Disposes] IDisposable disposable); | ||
} | ||
} |
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.
Just spaghetti:
[OwnedByCaller]
?[CallerOwns]
?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 think having
Disposable
somewhere in the name is good.