Nunit: SetCultureAttribute is absent

Created on 24 Jul 2016  ·  5Comments  ·  Source: nunit/nunit

I am trying to use SetCulture attribute on a test method with NUnit3 on .NET Core, but looks it is missing in nunit.framework assembly. Is it possible to use SetCulture with .NET core?

using NUnit.Framework;    

[Test]
[SetCulture("fr-FR")]
public void Test()
{
}

error CS0246: The type or namespace name 'SetCulture' could not be found (are you missing a using directive or an assembly reference?)

In project.json I reference this version of NUnit:
"NUnitLite" : "3.2.1",

done enhancement normal

Most helpful comment

Since it is now possible to support, I am going to reopen this as an enhancement.

All 5 comments

Currently, on .NET Core, you use the PCL build of the nunit framework, It's not possible to support setting the current culture in this build.

We are planning future netstandard builds, which may allow supporting this feature.

In _netcoreapp2.0_ and <PackageReference Include="NUnit" Version="3.7.1" /> this Attribute is (still) not available. Are there any plans / official workarounds?


I know that the culture can be set in code via Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("de-AT");

@gfoidl I believe that to support Culture, we will need to release a .NET Standard 2.0 version of NUnit. I expect we will add that target for 3.9, but it definately won't be in the upcoming 3.8 release.

Since it is now possible to support, I am going to reopen this as an enhancement.

This was fixed in #2895 in release 3.11.

@rprouse I've added the milestone and closed this issue. I hope it does not break anything, doing this "retrospectively"

Was this page helpful?
0 / 5 - 0 ratings