dotnet / dotnet/linker

Can't stub out a P/Invoke from an xml substitution file

Open
#2,586 0 comments 0 reactions 0 assignees View on GitHub
area-Linker: Steps
Dominant language
C#
Stars
392
Forks
128
Avg merge
2d 10h
Merged PRs (30d)
2

Description

It doesn't look like I can use an xml substitution file to stub out a P/Invoke, which while not a big issue, IMHO it would make sense to make it work.

Example xml:

```xml





```

Example cs:

```cs
namespace ObjCRuntime;
class Runtime {
[DllImport ("whatever")]
static extern int get_runtime_arch ();
}
```

Workaround:

```xml





```

```cs
namespace ObjCRuntime;
class Runtime {
[DllImport ("whatever")]
static extern int get_runtime_arch ();
static int GetRuntimeArch ()
{
return get_runtime_arch ();
}
}
```

and then the linker links away the P/Invoke, since it's not used anymore (after the substitution).

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.