Steps to reproduce:
- Download attached project and extract to folder.
- Restore packages, build.
- Observe error.
DllExport -version: v1.7.4.29858+c1cc52f
- Used Visual Studio / MSBuild : MSVS 17.1.0 / MSBuild 15.9.21+g9802d43bc3
Information from Data tab or log data:
data tab: dllexport-data-tab.txt
msbuild with /v:diag: build.log
Project Sample
Project zip: DllExport-Error-LibSandbox.zip
This is the code from Example.cs, but the entire project has been attached, so you may see my DllExport settings, as well as the overall project settings.
N.B.: This error becomes evident when built with C# language version 8+, with nullable reference types enabled. Using a Language version 7.3 or lower (no NRT), or setting nullable reference types to any setting other than enabled will not produce the error.
using LibSandbox.Native;
namespace LibSandbox
{
interface IFooProvider
{
object Inst { get; }
void Bar(object o);
}
class FooProvider : IFooProvider
{
public object Inst => new object();
public void Bar(object o) { }
}
public class Example
{
[DllExport]
public static void Baz() { }
}
}
Details
So this is a truly bizarre one that I've stumbled across today. I've narrowed it down to a very minimal reproducible example. It appears to be a combination of nullable reference types, and interface implementations.
With the project exactly as it is in the zip above, trying to rebuild will yield the error:
error : syntax error at token '.' in: .interfaceimpl type 'LibSandbox'.'IFooProvider' [...]
However, it seems to be extremely dependant on a number of things. Below, I've listed some modifications. Any single one of the changes below will allow the project to build successfully. Undo the change, and the error returns.
- Remove
IFooProvider.Inst (and subsequently FooProvider.Inst)
- Remove
IFooProvider.Bar (and subsequently FooProvider.Bar)
- Change
IFooProvider.Bar to take an int instead of object (and subsequently FooProvider.Bar)
- Remove the parameter from
IFooProvider.Bar (and subsequently FooProvider.Bar)
- Add
#nullable disable at the top of Example.cs
- Change
<Nullable>enable</Nullable> in LibSandbox.csproj to <Nullable>warnings</Nullable>
- Remove
[DllExport] from Example.Baz
- Remove the entire
FooProvider class.
Perhaps some other things would work around this issue, too.
Naturally, (as I'm sure you could imagine), I'm unable to make any of the changes in my actual project, which is why I've turned to posting here.
Let me know if there's more information I can provide!
Steps to reproduce:
DllExport -version: v1.7.4.29858+c1cc52fInformation from
Datatab or log data:data tab: dllexport-data-tab.txt
msbuild with /v:diag: build.log
Project Sample
Project zip: DllExport-Error-LibSandbox.zip
This is the code from
Example.cs, but the entire project has been attached, so you may see myDllExportsettings, as well as the overall project settings.N.B.: This error becomes evident when built with C# language version 8+, with nullable reference types enabled. Using a Language version 7.3 or lower (no NRT), or setting nullable reference types to any setting other than
enabledwill not produce the error.Details
So this is a truly bizarre one that I've stumbled across today. I've narrowed it down to a very minimal reproducible example. It appears to be a combination of nullable reference types, and interface implementations.
With the project exactly as it is in the zip above, trying to rebuild will yield the error:
However, it seems to be extremely dependant on a number of things. Below, I've listed some modifications. Any single one of the changes below will allow the project to build successfully. Undo the change, and the error returns.
IFooProvider.Inst(and subsequentlyFooProvider.Inst)IFooProvider.Bar(and subsequentlyFooProvider.Bar)IFooProvider.Barto take anintinstead ofobject(and subsequentlyFooProvider.Bar)IFooProvider.Bar(and subsequentlyFooProvider.Bar)#nullable disableat the top ofExample.cs<Nullable>enable</Nullable>inLibSandbox.csprojto<Nullable>warnings</Nullable>[DllExport]fromExample.BazFooProviderclass.Perhaps some other things would work around this issue, too.
Naturally, (as I'm sure you could imagine), I'm unable to make any of the changes in my actual project, which is why I've turned to posting here.
Let me know if there's more information I can provide!