-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Proposal: Expand supported Caller Info Attributes #351
Comments
That's a lot of optional parameters, maybe time for an object?
CallerInfo
|
Maybe. I wouldn't imagine that they would all be used in conjunction, but that could be useful as a convenience. |
@HaloFour Some attributes seem redundant:
|
That they are. Technically you wouldn't need anything beyond |
This would be very useful in log libraries, like NLog. We now use stacktrace for that, but those are not implemented in the new framework (yet?) https://github.com/dotnet/corefx/issues/1797 I think one object/struct would be better then a those optional parameters. |
If this will be implemented with a new type (e.g. |
I suppose CallerTypeName & CallerType etc. should be named CallerOwnerTypeName & CallerOwnerType and so on... And CallerType etc. or additional CallerMemberType etc. should be of the method return type (in case of property accessor, it has to be the property type). |
This has been moved to dotnet/csharplang#87 |
Problem:
The currently supported caller info attributes can only provide the name of the method, the name of the source file and the line number of the call in the source file. This is fine for scenarios such as simplifying implementations of
INotifyPropertyChanged
. However, if using these attributed for logging the amount of information available is quite limited.Solution:
Expand the number of supported caller info attributes to allow embedding additional diagnostic information. The following list is quite expansive to discuss/argue over the potential possibilities.
CallerColumnNumberAttribute: The column number of where the method is invoked.
CallerTypeNameAttribute: The simple name of the declaring type of the calling method.
CallerNamespaceAttribute: The namespace of the declaring type of the calling method.
CallerFullTypeNameAttribute: The full name of the declaring type of the calling method.
CallerTypeAttribute: The declaring type of the calling method. This is replaced by the compiler by
ldtoken
of the type followed by a call toType.GetTypeFromHandle
.CallerMethodAttribute: The MethodBase of the calling method. This is replaced by the compiler by
ldtoken
of the method reference followed by a call toMethodBase.GetMethodFromHandle
.Example usage:
The text was updated successfully, but these errors were encountered: