Skip to content

"error: syntax error at token '.' in .interfaceimpl type..." #205

Closed
@nitz

Description

@nitz

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions