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

Can you add GetMethods() #7

Open
vesnx opened this issue Nov 17, 2023 · 0 comments
Open

Can you add GetMethods() #7

vesnx opened this issue Nov 17, 2023 · 0 comments

Comments

@vesnx
Copy link

vesnx commented Nov 17, 2023

I was wondering if you could have a generic way to solve:

public Frame(StackFrame? frame)
{
    _methodBase = frame.GetMethod();
}


When you look at the inplementation you can see that it's not available in IOT

///


/// Returns the method the frame is executing
///

[RequiresUnreferencedCode("Metadata for the method might be incomplete or removed")]
public virtual MethodBase? GetMethod()
{
return _method;
}

       ```

if (exception is not null && exception.GetType().Name.Equals("SqlException", StringComparison.OrdinalIgnoreCase))
{
#pragma warning disable IL2075 // 'this' argument does not satisfy 'DynamicallyAccessedMembersAttribute' in call to target method. The return value of the source method does not have matching annotations.
var props = GetExceptionTypeWithProperties(exception).GetProperties(BindingFlags.Public | BindingFlags.Instance);
#pragma warning restore IL2075 // 'this' argument does not satisfy 'DynamicallyAccessedMembersAttribute' in call to target method. The return value of the source method does not have matching annotations.

            foreach (var property in props)
            {
                //sqlException
                switch (property.Name)
                {
                    case "Procedure":
                        _sqlProcedureName = property.GetValue(exception) as string;
                        break;

                    case "LineNumber":
                        if (property.GetValue(exception) is int iSqlLineNumber)
                            _sqlLineNumber = iSqlLineNumber;
                        break;

                    case "Number":
                        if (property.GetValue(exception) is int iSqlErrorNumber)
                            _sqlErrorNumber = iSqlErrorNumber;
                        break;

                    case "Server":
                        _sqlServer = property.GetValue(exception) as string;
                        break;

                    case "Source":
                        _tSql = property.GetValue(exception) as string;
                        break;

                    case "ErrorCode":
                        if (property.GetValue(exception) is int iSqlErrorCode)
                            _sqlErrorCode = iSqlErrorCode;
                        break;
                }
            }
        }
            
SqlException comes from more than one namespace and in my lib I do not reference any of them but I am still interested in sending crash diagnostics without having to write a special resolver for it.


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

1 participant