Skip to content

MissingMethodException - SessionStartEventArgs.GetPropertyValue #748

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

Closed
YulerB opened this issue Feb 28, 2020 · 4 comments
Closed

MissingMethodException - SessionStartEventArgs.GetPropertyValue #748

YulerB opened this issue Feb 28, 2020 · 4 comments
Labels
driver-collectors Issue related to collectors driver enhancement General enhancement request

Comments

@YulerB
Copy link

YulerB commented Feb 28, 2020

This new issue is related to #456, requested by @MarcoRossignoli

The difference is, this issue is to see if a fall-back in the code below would address the issue and allow us to use Coverlet using .net core 2.1.400.

Exception:

Data collector 'XPlat code coverage' message: System.MissingMethodException: Method not 
found: '!!0 
Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection.SessionStartEventArgs.GetProperty    Value(System.String)'.
   at     Coverlet.Collector.DataCollection.CoverletCoverageCollector.GetTestModules(SessionStartEventArgs sessionStartEventArgs)
   at Coverlet.Collector.DataCollection.CoverletCoverageCollector.OnSessionStart(Object sender,     SessionStartEventArgs sessionStartEventArgs).

Fallback:

    private static IEnumerable<string> GetPropertyValueWrapper(SessionStartEventArgs sessionStartEventArgs)
    {
        try
        {
            return sessionStartEventArgs.GetPropertyValue<IEnumerable<string>>(CoverletConstants.TestSourcesPropertyName);
        }
        catch (MissingMethodException)
        {
            using (var enumProperties = sessionStartEventArgs.GetProperties())
            {
                while (enumProperties.MoveNext())
                {
                    if (enumProperties.Current.Key == CoverletConstants.TestSourcesPropertyName &&
                        enumProperties.Current.Value is IEnumerable<string> propertyValue)
                    {
                        return propertyValue;
                    }
                }
            }
            throw;
        }
    }
@YulerB
Copy link
Author

YulerB commented Feb 29, 2020

From what I can tell, looks like test sources was added only in 2.1.7 in dotnet/cli#11312

@MarcoRossignoli MarcoRossignoli added driver-collectors Issue related to collectors driver enhancement General enhancement request labels Feb 29, 2020
@MarcoRossignoli
Copy link
Collaborator

@vagisha-nidhi does it make sense?

cc: @nohwnd

@MarcoRossignoli
Copy link
Collaborator

Closed for stale conversation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
driver-collectors Issue related to collectors driver enhancement General enhancement request
Projects
None yet
Development

No branches or pull requests

2 participants