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.
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
@MarcoRossignoli I would assume that the latest nightly of 3.0 preview 6 would have the bits? It's newer than 2.2.300.
Ah you're right completely missed that line...it's friday time to take a break...cc: @vagisha-nidhi that wrote collector.
AFAIK the change in 2.2.300 hasn't flowed into 3.x yet
@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
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.
@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.
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.
Thanks for info Oren!
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
);
}
@YulerB which versioin of sdk you want to use?Cannot compile with greather version but lower tfm?
Our build agents on RHEL 7 only support dotnet core sdk 2.1.400
@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.
Most helpful comment
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.