microsoft / CsWin32

A source generator to add a user-defined set of Win32 P/Invoke methods and supporting types to a C# project.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Missing compiler required member

Ksdmg opened this issue · comments

Actual behavior

When adding the apis QueryDosDevice and GetVolumePathNamesForVolumeName to a .NET Standard 2.0 project, a warning is generated and it's not possible to compile the project.

Severity	Code	Description	Project	Path	File	Line	Suppression State	Details
Error	CS0656	Missing compiler required member 'System.Runtime.CompilerServices.RuntimeHelpers.get_OffsetToStringData'	Incoe.Common.WinApi	~\Microsoft.Windows.CsWin32\Microsoft.Windows.CsWin32.SourceGenerator	~\Microsoft.Windows.CsWin32\Microsoft.Windows.CsWin32.SourceGenerator\Windows.Win32.PInvoke.KERNEL32.dll.g.cs	203	Active	

As soon as I change TargetFramework to at least net6.0 the project compiles without any code changes.

Expected behavior

The project should simply compile.

Repro steps

  1. NativeMethods.txt content:
QueryDosDevice
GetVolumePathNamesForVolumeName
  1. Any of your own code that should be shared?

Context

  • CsWin32 version: 0.3.49-beta
  • Target Framework: netstandard2.0
  • LangVersion 9

It works for me. Here's my repro project. It contains the same NativeMethods.txt file that yours does. Does it work for you?

CsWin32Sandbox.zip

Closing due to no response.