Skip to content

Commit 4dacc93

Browse files
Merge branch 'main' into feature/xSharpCompiler
2 parents 9ce3bf7 + 22a5b46 commit 4dacc93

File tree

11 files changed

+1180
-967
lines changed

11 files changed

+1180
-967
lines changed

Roslyn/src/Compilers/CSharp/Portable/Symbols/Source/SourcePropertySymbolBase.cs

+10-2
Original file line numberDiff line numberDiff line change
@@ -182,21 +182,25 @@ protected SourcePropertySymbolBase(
182182
}
183183
}
184184

185-
_sourceName = _sourceName ?? memberName; // _sourceName may have been set while loading attributes
186185
#if XSHARP
187-
if (syntax is IndexerDeclarationSyntax ids)
186+
_sourceName = memberName;
187+
// For indexed properties the name is in the ThisKeyword
188+
// For SELF properties the ThisKeyword has an empty name
189+
if (syntax is IndexerDeclarationSyntax ids && IsIndexedProperty)
188190
{
189191
_sourceName = ids.ThisKeyword.ValueText;
190192
}
191193
if (_isIndexedProperty)
192194
{
195+
// Check to see if we have an explicit interface
193196
_name = ExplicitInterfaceHelpers.GetMemberName(_sourceName, _explicitInterfaceType, aliasQualifierOpt);
194197
}
195198
else
196199
{
197200
_name = isIndexer ? ExplicitInterfaceHelpers.GetMemberName(WellKnownMemberNames.Indexer, _explicitInterfaceType, aliasQualifierOpt) : _sourceName;
198201
}
199202
#else
203+
_sourceName = _sourceName ?? memberName; // _sourceName may have been set while loading attributes
200204
_name = isIndexer ? ExplicitInterfaceHelpers.GetMemberName(WellKnownMemberNames.Indexer, _explicitInterfaceType, aliasQualifierOpt) : _sourceName;
201205
#endif
202206

@@ -659,6 +663,10 @@ public sealed override ImmutableArray<PropertySymbol> ExplicitInterfaceImplement
659663
if (IsExplicitInterfaceImplementation)
660664
{
661665
EnsureSignature();
666+
#if XSHARP
667+
if (_lazyExplicitInterfaceImplementations.IsDefault)
668+
_lazyExplicitInterfaceImplementations = ImmutableArray<PropertySymbol>.Empty;
669+
#endif
662670
}
663671
else
664672
{

Tests/Applications/R900/Prg/R900.prg

+102
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
using System.Reflection
2+
BEGIN NameSpace ConsoleApp1
3+
FUNCTION Start( ) AS VOID
4+
/*
5+
local oType := Typeof(test) as Type
6+
foreach oMem as MemberInfo in oType:GetMembers()
7+
if oMem is PropertyInfo VAR oProp
8+
? "Prop", oProp:Name, oProp:PropertyType
9+
foreach var oAcc in oProp:GetAccessors()
10+
if oAcc:DeclaringType == oType
11+
? "Accessor", oAcc:Name, oAcc:ReturnType
12+
endif
13+
next
14+
elseif oMem is MethodInfo var oMethod
15+
if oMethod:DeclaringType == oType
16+
? "Method", oMethod:Name, oMethod:ReturnType
17+
endif
18+
endif
19+
next
20+
? "InterfaceMap"
21+
var map := oType:GetInterfaceMap(typeof( ITest))
22+
foreach m as methodInfo in map:InterfaceMethods
23+
? m:Name, m:ReturnType
24+
next
25+
*/
26+
local oTest := Test{} as Test
27+
// indexed SELF property
28+
oTest[1] := "abc"
29+
? oTest[1]
30+
xAssert(oTest[1] == "abc1")
31+
LOCAL oTest2 := oTest as ITest
32+
? oTest2[1]
33+
oTest2[42] := "sometext" // sets it to "sometext42"
34+
? oTest2[1]
35+
xAssert((String)oTest2[1] == "ITestsometext421")
36+
// Indexed expression body
37+
? oTest:Foo[42]
38+
xAssert(oTest:Foo[42] == "42")
39+
? oTest:Foo2[4242]
40+
? oTest:Foo2[4242]
41+
xAssert(oTest:Foo2[4242] == "4242")
42+
RETURN
43+
44+
class Test IMPLEMENTS ITest
45+
PRIVATE sValue as sTRING
46+
47+
PROPERTY SELF[nItem as LONG] AS String
48+
GET
49+
RETURN sValue
50+
END GET
51+
SET
52+
sValue := value + nItem:ToString()
53+
END SET
54+
END PROPERTY
55+
PROPERTY ITest.SELF[nItem as LONG] AS object
56+
GET
57+
RETURN "ITest"+ (string) sValue +nItem:ToString()
58+
END GET
59+
SET
60+
sValue := ((string) value) +nItem:ToString()
61+
END SET
62+
END PROPERTY
63+
PROPERTY Custom[cItem as STRING] AS String
64+
GET
65+
RETURN sValue
66+
END GET
67+
SET
68+
sValue := value
69+
END SET
70+
END PROPERTY
71+
PROPERTY ITest.Custom[nItem as LONG] AS OBJECT
72+
GET
73+
RETURN sValue
74+
END GET
75+
SET
76+
sValue := (string) value
77+
END SET
78+
END PROPERTY
79+
METHOD TestMe() as STRING
80+
RETURN ""
81+
METHOD ITest.TestMe() as Object
82+
RETURN ""
83+
PROPERTY Foo[nItem as LONG] AS STRING => nItem:ToString()
84+
PROPERTY Foo2(nItem as LONG) AS STRING GET nItem:ToString()
85+
86+
END class
87+
88+
89+
INTERFACE ITest
90+
PROPERTY Custom[nItem as LONG] AS OBJECT GET SET
91+
PROPERTY SELF[nItem as LONG] AS OBJECT GET SET
92+
METHOD TestMe as OBJECT
93+
END INTERFACE
94+
END NAMESPACE
95+
96+
PROC xAssert(l AS LOGIC) AS VOID
97+
IF l
98+
? "Assertion passed"
99+
ELSE
100+
THROW Exception{"Incorrect result"}
101+
END IF
102+
RETURN

Tests/Applications/RuntimeTests/Prg/RuntimeTests.prg

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ FUNCTION Start() AS INT
4040
"R835", "R836", "R839", "R840", "R842", "R848", "R849", "R850", "R855", "R856", "R858",;
4141
"R861", "R862", "R863", "R864", "R865", "R868", "R870", "R871", "R872", "R873", ;
4242
"R875", "R876", "R878", "R879", "R883", "R884", "R885", "R886", "R888", "R889", ;
43-
"R890", "R892", "R895", "R897", "R899";
43+
"R890", "R892", "R895", "R897", "R899", "R900";
4444
}
4545

4646
#ifdef GUI

0 commit comments

Comments
 (0)