-
Notifications
You must be signed in to change notification settings - Fork 106
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
File attachments aren't added if they are prefixed with "\\?\" #1145
Comments
Can you add a small repro for this? How do you get file paths like that? Is it to circumvent max path length? |
Yes it's to handle long paths. Project file: <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="NUnit" Version="4.0.1" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
</ItemGroup>
</Project> Test code: using NUnit.Framework;
[TestFixture]
public class Tests
{
[Test]
public void LongPathTest()
{
TestContext.AddTestAttachment(@"\\?\C:\Temp\test.txt");
Assert.Fail();
}
} Run tests with: Output: |
Thanks! I'll add that to the test we have, and get this fixed. |
The next release of the framework, 4.2, should include a change which may help here by avoiding the need to explicitly specify the "\?" prefix: nunit/nunit#4353 Note that that change will still only include the prefix in the output file itself if it is explicitly specified as part of the |
When reporting a bug, please provide the following information to speed up triage:
NUnit and NUnit3TestAdapter versions
NUnit 3.14.0
NUnit3TestAdapter 4.5.0
Visual Studio edition and full version number (see Help About)
Visual Studio Professional 2022 64bit Version 17.8.3
A short repro, preferably attached or pointing to a git repo or gist
https://github.com/nunit/nunit3-vs-adapter/blob/master/src/NUnitTestAdapter/TestConverter.cs#L382C24-L382C24
Here the file path of the attachment is check with "new Uri()".
The Uri class throws an exception if the path prefix "\?" is used even though it's a valid path for Windows:
https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file?redirectedfrom=MSDN#maximum-path-length-limitation
This causes the attachments to be ignored even though they are actually there and valid.
A workaround would be to remove "\?" from the beginning if it's there before converting it to an Uri.
What .net platform and version is being targeted
.NET Framework 4.8
If TFS/VSTS issue, what version, hosted or on-premises, and what build task you see this in
None
The text was updated successfully, but these errors were encountered: