Skip to content

Commit 960fd37

Browse files
Removed internalProperties group from proxy and tests. (#75906)
Co-authored-by: Ilona Tomkowicz <itomkowicz@microsoft.com>
1 parent ad9abbe commit 960fd37

File tree

4 files changed

+24
-53
lines changed

4 files changed

+24
-53
lines changed

src/mono/wasm/debugger/BrowserDebugProxy/MemberObjectsExplorer.cs

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,7 @@ private static async Task<JObject> ReadFieldValue(
6868
fieldValue["__section"] = field.Attributes switch
6969
{
7070
FieldAttributes.Private => "private",
71-
FieldAttributes.Public => "result",
72-
_ => "internal"
71+
_ => "result"
7372
};
7473

7574
if (field.IsBackingField)
@@ -432,8 +431,7 @@ async Task UpdateBackingFieldWithPropertyAttributes(JObject backingField, string
432431
backingField["__section"] = getterMemberAccessAttrs switch
433432
{
434433
MethodAttributes.Private => "private",
435-
MethodAttributes.Public => "result",
436-
_ => "internal"
434+
_ => "result"
437435
};
438436
backingField["__state"] = state?.ToString();
439437

@@ -481,8 +479,7 @@ async Task AddProperty(
481479
propRet["__section"] = getterAttrs switch
482480
{
483481
MethodAttributes.Private => "private",
484-
MethodAttributes.Public => "result",
485-
_ => "internal"
482+
_ => "result"
486483
};
487484
propRet["__state"] = state?.ToString();
488485
if (parentTypeId != -1)
@@ -659,33 +656,28 @@ static void AddOnlyNewFieldValuesByNameTo(JArray namedValues, IDictionary<string
659656

660657
internal sealed class GetMembersResult
661658
{
662-
// public:
659+
// public / protected / internal:
663660
public JArray Result { get; set; }
664661
// private:
665662
public JArray PrivateMembers { get; set; }
666-
// protected / internal:
667-
public JArray OtherMembers { get; set; }
668663

669664
public JObject JObject => JObject.FromObject(new
670665
{
671666
result = Result,
672-
privateProperties = PrivateMembers,
673-
internalProperties = OtherMembers
667+
privateProperties = PrivateMembers
674668
});
675669

676670
public GetMembersResult()
677671
{
678672
Result = new JArray();
679673
PrivateMembers = new JArray();
680-
OtherMembers = new JArray();
681674
}
682675

683676
public GetMembersResult(JArray value, bool sortByAccessLevel)
684677
{
685678
var t = FromValues(value, sortByAccessLevel);
686679
Result = t.Result;
687680
PrivateMembers = t.PrivateMembers;
688-
OtherMembers = t.OtherMembers;
689681
}
690682

691683
public static GetMembersResult FromValues(IEnumerable<JToken> values, bool splitMembersByAccessLevel = false) =>
@@ -720,9 +712,6 @@ private void Split(JToken member)
720712
case "private":
721713
PrivateMembers.Add(member);
722714
return;
723-
case "internal":
724-
OtherMembers.Add(member);
725-
return;
726715
default:
727716
Result.Add(member);
728717
return;
@@ -733,7 +722,6 @@ private void Split(JToken member)
733722
{
734723
Result = (JArray)Result.DeepClone(),
735724
PrivateMembers = (JArray)PrivateMembers.DeepClone(),
736-
OtherMembers = (JArray)OtherMembers.DeepClone()
737725
};
738726

739727
public IEnumerable<JToken> Where(Func<JToken, bool> predicate)
@@ -752,26 +740,17 @@ public IEnumerable<JToken> Where(Func<JToken, bool> predicate)
752740
yield return item;
753741
}
754742
}
755-
foreach (var item in OtherMembers)
756-
{
757-
if (predicate(item))
758-
{
759-
yield return item;
760-
}
761-
}
762743
}
763744

764745
internal JToken FirstOrDefault(Func<JToken, bool> p)
765746
=> Result.FirstOrDefault(p)
766-
?? PrivateMembers.FirstOrDefault(p)
767-
?? OtherMembers.FirstOrDefault(p);
747+
?? PrivateMembers.FirstOrDefault(p);
768748

769749
internal JArray Flatten()
770750
{
771751
var result = new JArray();
772752
result.AddRange(Result);
773753
result.AddRange(PrivateMembers);
774-
result.AddRange(OtherMembers);
775754
return result;
776755
}
777756
public override string ToString() => $"{JObject}\n";

src/mono/wasm/debugger/BrowserDebugProxy/ValueTypeClass.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,7 @@ JObject GetFieldWithMetadata(FieldTypeClass field, JObject fieldValue, bool isSt
9898
if (isStatic)
9999
fieldValue["name"] = field.Name;
100100
FieldAttributes attr = field.Attributes & FieldAttributes.FieldAccessMask;
101-
fieldValue["__section"] = attr == FieldAttributes.Public
102-
? "public" :
103-
attr == FieldAttributes.Private ? "private" : "internal";
101+
fieldValue["__section"] = attr == FieldAttributes.Private ? "private" : "result";
104102

105103
if (field.IsBackingField)
106104
{
@@ -218,7 +216,6 @@ public async Task<GetMembersResult> GetMemberValues(
218216
result = _combinedResult.Clone();
219217
RemovePropertiesFrom(result.Result);
220218
RemovePropertiesFrom(result.PrivateMembers);
221-
RemovePropertiesFrom(result.OtherMembers);
222219
}
223220

224221
if (result == null)

src/mono/wasm/debugger/DebuggerTestSuite/DebuggerTestBase.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -988,7 +988,7 @@ internal virtual async Task<JToken> GetProperties(string id, JToken fn_args = nu
988988
return locals;
989989
}
990990

991-
internal async Task<(JToken, JToken, JToken)> GetPropertiesSortedByProtectionLevels(string id, JToken fn_args = null, bool? own_properties = null, bool? accessors_only = null, bool expect_ok = true)
991+
internal async Task<(JToken, JToken)> GetPropertiesSortedByProtectionLevels(string id, JToken fn_args = null, bool? own_properties = null, bool? accessors_only = null, bool expect_ok = true)
992992
{
993993
if (UseCallFunctionOnBeforeGetProperties && !id.StartsWith("dotnet:scope:"))
994994
{
@@ -1004,7 +1004,7 @@ internal virtual async Task<JToken> GetProperties(string id, JToken fn_args = nu
10041004
var result = await cli.SendCommand("Runtime.callFunctionOn", cfo_args, token);
10051005
AssertEqual(expect_ok, result.IsOk, $"Runtime.getProperties returned {result.IsOk} instead of {expect_ok}, for {cfo_args.ToString()}, with Result: {result}");
10061006
if (!result.IsOk)
1007-
return (null, null, null);
1007+
return (null, null);
10081008
id = result.Value["result"]?["objectId"]?.Value<string>();
10091009
}
10101010

@@ -1024,10 +1024,9 @@ internal virtual async Task<JToken> GetProperties(string id, JToken fn_args = nu
10241024
var frame_props = await cli.SendCommand("Runtime.getProperties", get_prop_req, token);
10251025
AssertEqual(expect_ok, frame_props.IsOk, $"Runtime.getProperties returned {frame_props.IsOk} instead of {expect_ok}, for {get_prop_req}, with Result: {frame_props}");
10261026
if (!frame_props.IsOk)
1027-
return (null, null, null);;
1027+
return (null, null);;
10281028

10291029
var locals = frame_props.Value["result"];
1030-
var locals_internal = frame_props.Value["internalProperties"];
10311030
var locals_private = frame_props.Value["privateProperties"];
10321031

10331032
// FIXME: Should be done when generating the list in dotnet.es6.lib.js, but not sure yet
@@ -1044,7 +1043,7 @@ internal virtual async Task<JToken> GetProperties(string id, JToken fn_args = nu
10441043
}
10451044
}
10461045

1047-
return (locals, locals_internal, locals_private);
1046+
return (locals, locals_private);
10481047
}
10491048

10501049
internal virtual async Task<(JToken, Result)> EvaluateOnCallFrame(string id, string expression, bool expect_ok = true)

src/mono/wasm/debugger/DebuggerTestSuite/GetPropertiesTests.cs

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -449,12 +449,13 @@ private void AssertHasOnlyExpectedProperties(string[] expected_names, IEnumerabl
449449
throw new XunitException($"missing or unexpected members found");
450450
}
451451

452-
public static TheoryData<Dictionary<string, JObject>, Dictionary<string, JObject>, Dictionary<string, JObject>, string> GetDataForProtectionLevels()
452+
public static TheoryData<Dictionary<string, JObject>, Dictionary<string, JObject>, string> GetDataForProtectionLevels()
453453
{
454-
var data = new TheoryData<Dictionary<string, JObject>, Dictionary<string, JObject>, Dictionary<string, JObject>, string>();
454+
var data = new TheoryData<Dictionary<string, JObject>, Dictionary<string, JObject>, string>();
455455

456456
var public_props = new Dictionary<string, JObject>()
457457
{
458+
// --------- public ------------:
458459
// own:
459460
{"BaseBase_PropertyForHidingWithField", TNumber(210)},
460461
{"Base_PropertyForOverridingWithProperty", TGetter("Base_PropertyForOverridingWithProperty", TDateTime(new DateTime(2020, 7, 6, 5, 4, 3)))},
@@ -487,10 +488,8 @@ public static TheoryData<Dictionary<string, JObject>, Dictionary<string, JObject
487488
{"BaseBase_AutoPropertyForHidingWithAutoProperty (BaseBaseClass2)", TString("BaseBase#BaseBase_AutoPropertyForHidingWithAutoProperty")},
488489
{"BaseBase_PropertyForVHO (BaseBaseClass2)", TGetter("BaseBase_PropertyForVHO (BaseBaseClass2)", TString("BaseBase#BaseBase_PropertyForVHO"))},
489490
{"BaseBase_AutoPropertyForVHO (BaseBaseClass2)", TString("BaseBase#BaseBase_AutoPropertyForVHO")},
490-
};
491-
492-
var internal_protected_props = new Dictionary<string, JObject>(){
493491

492+
// ---- internal / protected ----:
494493
// own:
495494
{"BaseBase_AutoPropertyForHidingWithProperty", TGetter("BaseBase_AutoPropertyForHidingWithProperty", TString("Derived#BaseBase_AutoPropertyForHidingWithProperty"))},
496495
{"Base_PropertyForOverridingWithAutoProperty", TDateTime(new DateTime(2022, 7, 6, 5, 4, 3))},
@@ -510,20 +509,19 @@ public static TheoryData<Dictionary<string, JObject>, Dictionary<string, JObject
510509
{"BaseBase_AutoPropertyForHidingWithProperty (BaseClass2)", TGetter("BaseBase_AutoPropertyForHidingWithProperty (BaseClass2)", TString("Base#BaseBase_AutoPropertyForHidingWithProperty"))},
511510
{"BaseBase_PropertyForHidingWithAutoProperty", TString("Base#BaseBase_PropertyForHidingWithAutoProperty")},
512511
};
513-
data.Add(public_props, internal_protected_props, private_props, "DerivedClass2");
512+
data.Add(public_props, private_props, "DerivedClass2");
514513

515514
// structure CloneableStruct:
516515
public_props = new Dictionary<string, JObject>()
517516
{
518517
// own
518+
// public
519519
{"a", TNumber(4)},
520520
{"DateTime", TGetter("DateTime")},
521521
{"AutoStringProperty", TString("CloneableStruct#AutoStringProperty")},
522522
{"FirstName", TGetter("FirstName")},
523-
{"LastName", TGetter("LastName")}
524-
};
525-
internal_protected_props = new Dictionary<string, JObject>()
526-
{
523+
{"LastName", TGetter("LastName")},
524+
527525
// internal
528526
{"b", TBool(true)}
529527
};
@@ -533,29 +531,27 @@ public static TheoryData<Dictionary<string, JObject>, Dictionary<string, JObject
533531
{"_dateTime", TDateTime(new DateTime(2020, 7, 6, 5, 4, 3 + 3))},
534532
{"_DTProp", TGetter("_DTProp")}
535533
};
536-
data.Add(public_props, internal_protected_props, private_props, "CloneableStruct");
534+
data.Add(public_props, private_props, "CloneableStruct");
537535
return data;
538536
}
539537

540538
[ConditionalTheory(nameof(RunningOnChrome))]
541539
[MemberData(nameof(GetDataForProtectionLevels))]
542540
public async Task PropertiesSortedByProtectionLevel(
543-
Dictionary<string, JObject> expectedPublic, Dictionary<string, JObject> expectedProtInter, Dictionary<string, JObject> expectedPriv, string entryMethod) =>
541+
Dictionary<string, JObject> expectedPublicInternalAndProtected, Dictionary<string, JObject> expectedPriv, string entryMethod) =>
544542
await CheckInspectLocalsAtBreakpointSite(
545543
$"DebuggerTests.GetPropertiesTests.{entryMethod}", "InstanceMethod", 1, $"DebuggerTests.GetPropertiesTests.{entryMethod}.InstanceMethod",
546544
$"window.setTimeout(function() {{ invoke_static_method ('[debugger-test] DebuggerTests.GetPropertiesTests.{entryMethod}:run'); }})",
547545
wait_for_event_fn: async (pause_location) =>
548546
{
549547
var id = pause_location["callFrames"][0]["callFrameId"].Value<string>();
550548
var (obj, _) = await EvaluateOnCallFrame(id, "this");
551-
var (pub, internalAndProtected, priv) = await GetPropertiesSortedByProtectionLevels(obj["objectId"]?.Value<string>());
549+
var (pubInternalAndProtected, priv) = await GetPropertiesSortedByProtectionLevels(obj["objectId"]?.Value<string>());
552550

553-
AssertHasOnlyExpectedProperties(expectedPublic.Keys.ToArray(), pub.Values<JObject>());
554-
AssertHasOnlyExpectedProperties(expectedProtInter.Keys.ToArray(), internalAndProtected.Values<JObject>());
551+
AssertHasOnlyExpectedProperties(expectedPublicInternalAndProtected.Keys.ToArray(), pubInternalAndProtected.Values<JObject>());
555552
AssertHasOnlyExpectedProperties(expectedPriv.Keys.ToArray(), priv.Values<JObject>());
556553

557-
await CheckProps(pub, expectedPublic, "public");
558-
await CheckProps(internalAndProtected, expectedProtInter, "internalAndProtected");
554+
await CheckProps(pubInternalAndProtected, expectedPublicInternalAndProtected, "result");
559555
await CheckProps(priv, expectedPriv, "private");
560556
});
561557
}

0 commit comments

Comments
 (0)