Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitad685d4

Browse files
0x53AKevinRansom
authored andcommitted
Fix 1373: add checks for famANDassembly visibility (#2495)
* add checks for famANDassembly visibilityfixesdotnet/fsharp#1373* add unit tests for FamAndAssembly / FamOrAssembly* disable failing test* adapt ut error message for error message rework* add issue link to disabled unit test* align and replace all tabs with whitespace (maybe build failure is related to tabs? I'm probably paranoid ....)* -a => --target:library* fix assembly* fix FamAndAssembly* manually modify accessibilities in AccessibilityTests.dll* Revert "-a => --target:library"This reverts commit 33af6458fc2839511e7b110b4b0c3922ff95fa4e.
1 parent38f489a commitad685d4

File tree

8 files changed

+76
-1
lines changed

8 files changed

+76
-1
lines changed

‎src/fsharp/AccessibilityLogic.fs‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,15 @@ let private IsILMemberAccessible g amap m (tcrefOfViewedItem : TyconRef) ad acce
9090
(access= ILMemberAccess.Assembly|| access= ILMemberAccess.FamilyOrAssembly)&&
9191
canAccessFromOneOf cpaths tcrefOfViewedItem.CompilationPath
9292

93-
(access= ILMemberAccess.Public)|| accessibleByFamily|| accessibleByInternalsVisibleTo
93+
letaccessibleByFamilyAndAssembly=
94+
access= ILMemberAccess.FamilyAndAssembly&&
95+
canAccessFromOneOf cpaths tcrefOfViewedItem.CompilationPath&&
96+
match tcrefViewedFromOptionwith
97+
| None->false
98+
| Some tcrefViewedFrom->
99+
ExistsHeadTypeInEntireHierarchy g amap m(generalizedTyconRef tcrefViewedFrom) tcrefOfViewedItem
100+
101+
(access= ILMemberAccess.Public)|| accessibleByFamily|| accessibleByInternalsVisibleTo|| accessibleByFamilyAndAssembly
94102

95103
| AccessibleFromSomewhere->
96104
true
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
usingSystem.Runtime.CompilerServices;
2+
3+
[assembly:InternalsVisibleTo("FamAndAssembly")]
4+
[assembly:InternalsVisibleTo("FamOrAssembly")]
5+
6+
7+
publicclassAccessibility
8+
{
9+
publicintPublic{get;set;}
10+
privateintPrivate{get;set;}
11+
protectedintProtected{get;set;}
12+
internalintInternal{get;set;}
13+
// Note: accessibility was modified using dnspy
14+
publicintFamOrAssembly{get;set;}
15+
// Note: accessibility was modified using dnspy
16+
publicintFamAndAssembly{get;set;}
17+
}
18+
4.5 KB
Binary file not shown.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// #Regression #NoMT #Import
2+
3+
namespaceNS
4+
5+
typeT()=
6+
// note: the assembly 'Accessibility' has an IVT to this assembly
7+
inherit Accessibility()
8+
memberx.Test()=base.FamAndAssembly
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// #Regression #NoMT #Import
2+
//<Expects status="error" span="(8,28)" id="FS0039">The field, constructor or member 'FamAndAssembly' is not defined.</Expects>
3+
namespaceNS
4+
5+
typeT()=
6+
// note: the assembly 'Accessibility' does NOT have an IVT to this assembly, so it is expected to fail.
7+
inherit Accessibility()
8+
memberx.Test()=base.FamAndAssembly
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// #Regression #NoMT #Import
2+
3+
namespaceNS
4+
5+
// note: the assembly 'Accessibility' has an IVT to this assembly
6+
7+
typeT()=
8+
inherit Accessibility()
9+
memberx.Test()=base.FamOrAssembly
10+
11+
moduleM=
12+
letTest()= Accessibility().FamOrAssembly
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// #Regression #NoMT #Import
2+
//<Expects status="error" span="(12,18)" id="FS0491">The member or object constructor 'FamOrAssembly' is not accessible. Private members may only be accessed from within the declaring type. Protected members may only be accessed from an extending type and cannot be accessed from inner lambda expressions.</Expects>
3+
namespaceNS
4+
5+
// with FamOrAssembly, this should succeed, even though there is no IVT
6+
typeT()=
7+
inherit Accessibility()
8+
memberx.Test()=base.FamOrAssembly
9+
10+
moduleM=
11+
// note: the assembly 'Accessibility' does NOT have an IVT to this assembly, so it is expected to fail.
12+
letTest()= Accessibility().FamOrAssembly

‎tests/fsharpqa/Source/Import/env.lst‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,15 @@ NOMONOSOURCE=reference2.fsx SCFLAGS="--nologo -r:reference1.dll" PRECMD="\$FSC_
8080
SOURCE=InternalsConsumer.fs SCFLAGS="-r:InternalsConsumer.CSAssembly.dll" PRECMD="\$CSC_PIPE /t:library InternalsConsumer.CSAssembly.cs"# InternalsConsumer.fs
8181
SOURCE=E_InternalsConsumer.fs SCFLAGS="-r:InternalsConsumer.CSAssembly.dll" PRECMD="\$CSC_PIPE /t:library InternalsConsumer.CSAssembly.cs"# E_InternalsConsumer.fs
8282

83+
###
84+
### F# can consume FamOrAssembly and FamAndAssembly in combination with IVT
85+
###
86+
SOURCE=FamAndAssembly.fs SCFLAGS="-a -r:AccessibilityTests.dll" # FamAndAssembly.fs
87+
### See issue https://github.com/Microsoft/visualfsharp/issues/2496
88+
### SOURCE=FamOrAssembly.fs SCFLAGS="-a -r:AccessibilityTests.dll" # FamOrAssembly.fs
89+
SOURCE=FamAndAssembly_NoIVT.fs SCFLAGS="-a -r:AccessibilityTests.dll" # FamAndAssembly_NoIVT.fs
90+
### SOURCE=FamOrAssembly_NoIVT.fs SCFLAGS="-a -r:AccessibilityTests.dll" # FamOrAssembly_NoIVT.fs
91+
8392
###
8493
### Iterate over BCL collections
8594
###

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp