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

Missing method with vstest integration #456

Closed
clairernovotny opened this issue Jun 7, 2019 · 13 comments
Closed

Missing method with vstest integration #456

clairernovotny opened this issue Jun 7, 2019 · 13 comments
Labels
needs more info More details are needed question This issue is a question

Comments

@clairernovotny
Copy link
Contributor

clairernovotny commented Jun 7, 2019

Hi,

I'm trying to use the VSTest integration and getting the following:

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

I'm using the .NET Core 3 SDK Preview 6 3.0.100-preview6-012262.

The test project has the following:

<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.1.1" />
<PackageReference Include="coverlet.collector" Version="1.0.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" />
<PackageReference Include="FluentAssertions" Version="5.6.0" />
<PackageReference Include="xunit" Version="2.4.1" />

I also tried with Microsoft.NET.Test.SDK 16.2.0-preview-20190606-02, which was just published 5 hours ago.

@MarcoRossignoli
Copy link
Collaborator

MarcoRossignoli commented Jun 7, 2019

https://github.com/tonerdo/coverlet/blob/master/README.md#vstest-integration Note: You need to be running .NET Core SDK v2.2.300 and above I hitted same error testing with old sdk

@clairernovotny
Copy link
Contributor Author

@MarcoRossignoli I would assume that the latest nightly of 3.0 preview 6 would have the bits? It's newer than 2.2.300.

@MarcoRossignoli
Copy link
Collaborator

Ah you're right completely missed that line...it's friday time to take a break...cc: @vagisha-nidhi that wrote collector.

@MarcoRossignoli MarcoRossignoli added question This issue is a question needs more info More details are needed labels Jun 7, 2019
@ViktorHofer
Copy link
Contributor

ViktorHofer commented Jun 7, 2019

AFAIK the change in 2.2.300 hasn't flowed into 3.x yet

@vagisha-nidhi
Copy link
Contributor

@ViktorHofer is correct. The 2.2.300 changes haven't flown into 3.x Preview 6.
@MarcoRossignoli

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

Should this message be replaced with something more informative (like using the correct sdk version)?

cc: @cltshivash

@MarcoRossignoli
Copy link
Collaborator

Should this message be replaced with something more informative (like using the correct sdk version)?

@vagisha-nidhi yes I agree this error is a bit cryptic. Maybe improve with some advice(catch MissingMethodException and output message like Method not found, make sure to use .NET core SDK version >= 2.2.300 and flow real exc as inner) if we aren't sure that this kind of exception raise only in case of unsupported sdk.

@MarcoRossignoli
Copy link
Collaborator

MarcoRossignoli commented Jun 9, 2019

@onovotny I close issue because the question has been anwered by @vagisha-nidhi The 2.2.300 changes haven't flown into 3.x Preview 6.

@clairernovotny
Copy link
Contributor Author

Update for anyone following along -- the 16.1.1 vstest runner has been merged into the latest .NET Core 3 Preview 7 nightlies, so this works now.

@MarcoRossignoli
Copy link
Collaborator

Thanks for info Oren!

@YulerB
Copy link

YulerB commented Feb 27, 2020

Would fallback's be available to lower the framework version?

    private static IEnumerable<string> GetPropertyValueWrapper(SessionStartEventArgs sessionStartEventArgs)
    {
        try
        {
            return sessionStartEventArgs.GetPropertyValue<IEnumerable<string>>(CoverletConstants.TestSourcesPropertyName);
        }
        catch (MissingMethodException ex)
        {
            using (var enumProperties = sessionStartEventArgs.GetProperties())
            {
                while (enumProperties.MoveNext())
                {
                    if (enumProperties.Current.Key == CoverletConstants.TestSourcesPropertyName)
                    {
                        return enumProperties.Current.Value as IEnumerable<string>;
                    }
                }
            }
            throw ex;
        }

or something like:

    private static IEnumerable<string> GetPropertyValueWrapper(SessionStartEventArgs sessionStartEventArgs)
    {
        try
        {
            return sessionStartEventArgs.GetPropertyValue<IEnumerable<string>>(CoverletConstants.TestSourcesPropertyName);
        }
        catch (MissingMethodException ex)
        {
            using (var enumProperties = sessionStartEventArgs.GetProperties())
            {
                while (enumProperties.MoveNext())
                {
                    if (enumProperties.Current.Key == CoverletConstants.TestSourcesPropertyName)
                    {
                        return enumProperties.Current.Value as IEnumerable<string>;
                    }
                }
            }
            return sessionStartEventArgs.Context.TestCase.GetPropertyValue<IEnumerable<string>>(
                TestProperty.Find(CoverletConstants.TestSourcesPropertyName), null
            );
        }

@MarcoRossignoli
Copy link
Collaborator

@YulerB which versioin of sdk you want to use?Cannot compile with greather version but lower tfm?

@YulerB
Copy link

YulerB commented Feb 28, 2020

Our build agents on RHEL 7 only support dotnet core sdk 2.1.400

@MarcoRossignoli
Copy link
Collaborator

@YulerB can you open new issue?
MS team wrote first version of collector, so I'm not sure if your workaround will works, if you open new issue I can cc ms team member and together will understand if makes sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs more info More details are needed question This issue is a question
Projects
None yet
Development

No branches or pull requests

5 participants