You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
InternalsVisibleTo + internal module + inline function error message could be improved #7110
I think that the code should compile successfully. But even if it isn't, then the compiler should print a sensible error message.
Actual behavior
The code doesn't compile and the compiler provides rather cryptic messages:
LibProject\LibProject.fs(9,12): Error FS1113 : The value 'int32FromBigEndian' was marked inline but its implementation makes use of an internal or private function which is not sufficiently accessible
TestProject\TestProject.fs(6,14): Warning FS1116 : A value marked as 'inline' has an unexpected value
TestProject\TestProject.fs(6,14): Error FS1118 : Failed to inline the value 'int32FromBigEndian' marked 'inline', perhaps because a recursive value was marked 'inline'
Known workarounds
Well, don't use inline functions within internal modules with the InternalsVisibleTo attribute :)
Related information
Reproduced using .NET Core SDK:
$ dotnet --info
.NET Core SDK (reflecting any global.json):
Version: 2.2.300
Commit: 73efd5bd87
Runtime Environment:
OS Name: Windows
OS Version: 10.0.18362
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\2.2.300\
Host (useful for support):
Version: 2.2.5
Commit: 0a3c9209c0
Reacted by Roman Melnikov, Evgeniy Andreev, Vladimir Shchur and Eugene Auduchinok
Well, don't use inline functions within internal modules with the InternalsVisibleTo attribute :)
This is correct - InternalsVisibleTo doesn't allow inlining across assembly boundaries and if you try to use both of these you will get the above errors. So this is by design.
I think that the error message could be improved. Let's consider the first one:
The value 'int32FromBigEndian' was marked inline but its implementation makes use of an internal or private function which is not sufficiently accessible
I can't see which "internal or private function" do int32FromBigEndian use. It uses only IPAddress.NetworkToHostOrder which is a public static method. But probably "the value 'int32FromBigEndian'" isn't the function body but something else, and I don't understand the error message?
Maybe we could change the text so it's more clear?
The value 'int32FromBigEndian' refers to an internal or private function which is not sufficiently accessible
The second message looks okay if you don't read the "perhaps" part, and the warning is probably okay, too.
The private/internal thing is int32FromBigEndian itself. So you can access it via InternalsVisibleTo but compilation will fail because the inlining information is thrown away at the assembly boundary.
We could indeed add a compilation error for that specific case (direct access to an internal inline function from another assembly via IVT).
Note we could really choose to keep the "internal" inlining information in the assembly whenever there is an IVT just in case the inline functions get used. But we don't do that to ensure assemblies are not bloated.
Okay, I understand that int32FromBigEndian is internal. But error message states that the implementation of int32FromBigEndian makes use of some other "private/internal symbol", and that part is confusing (I was legitimately confused by it). The message hints me that I should read the implementation of this function, and that isn't helpful, because the problem isn't in the implementation, but in the function itself (or even in the declaring module).
Okay, I understand that int32FromBigEndian is internal. But error message states that the implementation of int32FromBigEndian refers to some other "private/internal symbol", and that part is confusing (I was legitimately confused by it). The message hints me that I should read the implementation of this function, and that isn't helpful, because the problem isn't in the implementation, but in the function itself (or even in the declaring module) .
changed the title [-]InternalsVisibleTo + internal module + inline function error[/-][+]InternalsVisibleTo + internal module + inline function error message could be improved[/+]on Jul 4, 2019
Ran into this today and this today and spent 30 min trying to figure out what the issue was. Had to come here to the repo, search for the specific error message, sift through these issues just to figure out exactly what was going wrong. Not user friendly at all imo.
Activity
dsyme commentedon Jul 3, 2019
This is correct - InternalsVisibleTo doesn't allow inlining across assembly boundaries and if you try to use both of these you will get the above errors. So this is by design.
ForNeVeR commentedon Jul 3, 2019
I think that the error message could be improved. Let's consider the first one:
I can't see which "internal or private function" do
int32FromBigEndianuse. It uses onlyIPAddress.NetworkToHostOrderwhich is a public static method. But probably "the value 'int32FromBigEndian'" isn't the function body but something else, and I don't understand the error message?Maybe we could change the text so it's more clear?
The second message looks okay if you don't read the "perhaps" part, and the warning is probably okay, too.
dsyme commentedon Jul 3, 2019
The private/internal thing is
int32FromBigEndianitself. So you can access it via InternalsVisibleTo but compilation will fail because the inlining information is thrown away at the assembly boundary.We could indeed add a compilation error for that specific case (direct access to an internal
inlinefunction from another assembly via IVT).Note we could really choose to keep the "internal" inlining information in the assembly whenever there is an IVT just in case the
inlinefunctions get used. But we don't do that to ensure assemblies are not bloated.ForNeVeR commentedon Jul 3, 2019
Okay, I understand that
int32FromBigEndianis internal. But error message states that the implementation ofint32FromBigEndianmakes use of some other "private/internal symbol", and that part is confusing (I was legitimately confused by it). The message hints me that I should read the implementation of this function, and that isn't helpful, because the problem isn't in the implementation, but in the function itself (or even in the declaring module).dsyme commentedon Jul 4, 2019
Yes, absolutely, the error message is rotten
[-]InternalsVisibleTo + internal module + inline function error[/-][+]InternalsVisibleTo + internal module + inline function error message could be improved[/+]cartermp commentedon Jul 4, 2019
Tagging as a feature improvement
g5becks commentedon Apr 30, 2023
Ran into this today and this today and spent 30 min trying to figure out what the issue was. Had to come here to the repo, search for the specific error message, sift through these issues just to figure out exactly what was going wrong. Not user friendly at all imo.