未验证 提交 104c6e16 编写于 作者: I Ilona Tomkowicz 提交者: GitHub

Removed internalProperties group from proxy and tests. (#75904)

上级 4fae3c63
......@@ -68,8 +68,7 @@ private static string GetNamePrefixForValues(string memberName, string typeName,
fieldValue["__section"] = field.Attributes switch
{
FieldAttributes.Private => "private",
FieldAttributes.Public => "result",
_ => "internal"
_ => "result"
};
if (field.IsBackingField)
......@@ -432,8 +431,7 @@ async Task UpdateBackingFieldWithPropertyAttributes(JObject backingField, string
backingField["__section"] = getterMemberAccessAttrs switch
{
MethodAttributes.Private => "private",
MethodAttributes.Public => "result",
_ => "internal"
_ => "result"
};
backingField["__state"] = state?.ToString();
......@@ -481,8 +479,7 @@ async Task UpdateBackingFieldWithPropertyAttributes(JObject backingField, string
propRet["__section"] = getterAttrs switch
{
MethodAttributes.Private => "private",
MethodAttributes.Public => "result",
_ => "internal"
_ => "result"
};
propRet["__state"] = state?.ToString();
if (parentTypeId != -1)
......@@ -659,25 +656,21 @@ static void AddOnlyNewFieldValuesByNameTo(JArray namedValues, IDictionary<string
internal sealed class GetMembersResult
{
// public:
// public / protected / internal:
public JArray Result { get; set; }
// private:
public JArray PrivateMembers { get; set; }
// protected / internal:
public JArray OtherMembers { get; set; }
public JObject JObject => JObject.FromObject(new
{
result = Result,
privateProperties = PrivateMembers,
internalProperties = OtherMembers
privateProperties = PrivateMembers
});
public GetMembersResult()
{
Result = new JArray();
PrivateMembers = new JArray();
OtherMembers = new JArray();
}
public GetMembersResult(JArray value, bool sortByAccessLevel)
......@@ -685,7 +678,6 @@ public GetMembersResult(JArray value, bool sortByAccessLevel)
var t = FromValues(value, sortByAccessLevel);
Result = t.Result;
PrivateMembers = t.PrivateMembers;
OtherMembers = t.OtherMembers;
}
public static GetMembersResult FromValues(IEnumerable<JToken> values, bool splitMembersByAccessLevel = false) =>
......@@ -720,9 +712,6 @@ private void Split(JToken member)
case "private":
PrivateMembers.Add(member);
return;
case "internal":
OtherMembers.Add(member);
return;
default:
Result.Add(member);
return;
......@@ -733,7 +722,6 @@ public GetMembersResult Clone() => new GetMembersResult()
{
Result = (JArray)Result.DeepClone(),
PrivateMembers = (JArray)PrivateMembers.DeepClone(),
OtherMembers = (JArray)OtherMembers.DeepClone()
};
public IEnumerable<JToken> Where(Func<JToken, bool> predicate)
......@@ -752,26 +740,17 @@ public IEnumerable<JToken> Where(Func<JToken, bool> predicate)
yield return item;
}
}
foreach (var item in OtherMembers)
{
if (predicate(item))
{
yield return item;
}
}
}
internal JToken FirstOrDefault(Func<JToken, bool> p)
=> Result.FirstOrDefault(p)
?? PrivateMembers.FirstOrDefault(p)
?? OtherMembers.FirstOrDefault(p);
?? PrivateMembers.FirstOrDefault(p);
internal JArray Flatten()
{
var result = new JArray();
result.AddRange(Result);
result.AddRange(PrivateMembers);
result.AddRange(OtherMembers);
return result;
}
public override string ToString() => $"{JObject}\n";
......
......@@ -98,9 +98,7 @@ JObject GetFieldWithMetadata(FieldTypeClass field, JObject fieldValue, bool isSt
if (isStatic)
fieldValue["name"] = field.Name;
FieldAttributes attr = field.Attributes & FieldAttributes.FieldAccessMask;
fieldValue["__section"] = attr == FieldAttributes.Public
? "public" :
attr == FieldAttributes.Private ? "private" : "internal";
fieldValue["__section"] = attr == FieldAttributes.Private ? "private" : "result";
if (field.IsBackingField)
{
......@@ -218,7 +216,6 @@ public async Task<JArray> GetProxy(MonoSDBHelper sdbHelper, CancellationToken to
result = _combinedResult.Clone();
RemovePropertiesFrom(result.Result);
RemovePropertiesFrom(result.PrivateMembers);
RemovePropertiesFrom(result.OtherMembers);
}
// 4 - fields + properties
......
......@@ -988,7 +988,7 @@ internal virtual async Task<JToken> GetProperties(string id, JToken fn_args = nu
return locals;
}
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)
internal async Task<(JToken, JToken)> GetPropertiesSortedByProtectionLevels(string id, JToken fn_args = null, bool? own_properties = null, bool? accessors_only = null, bool expect_ok = true)
{
if (UseCallFunctionOnBeforeGetProperties && !id.StartsWith("dotnet:scope:"))
{
......@@ -1004,7 +1004,7 @@ internal async Task<(JToken, JToken, JToken)> GetPropertiesSortedByProtectionLev
var result = await cli.SendCommand("Runtime.callFunctionOn", cfo_args, token);
AssertEqual(expect_ok, result.IsOk, $"Runtime.getProperties returned {result.IsOk} instead of {expect_ok}, for {cfo_args.ToString()}, with Result: {result}");
if (!result.IsOk)
return (null, null, null);
return (null, null);
id = result.Value["result"]?["objectId"]?.Value<string>();
}
......@@ -1024,10 +1024,9 @@ internal async Task<(JToken, JToken, JToken)> GetPropertiesSortedByProtectionLev
var frame_props = await cli.SendCommand("Runtime.getProperties", get_prop_req, token);
AssertEqual(expect_ok, frame_props.IsOk, $"Runtime.getProperties returned {frame_props.IsOk} instead of {expect_ok}, for {get_prop_req}, with Result: {frame_props}");
if (!frame_props.IsOk)
return (null, null, null);;
return (null, null);;
var locals = frame_props.Value["result"];
var locals_internal = frame_props.Value["internalProperties"];
var locals_private = frame_props.Value["privateProperties"];
// FIXME: Should be done when generating the list in dotnet.es6.lib.js, but not sure yet
......@@ -1044,7 +1043,7 @@ internal async Task<(JToken, JToken, JToken)> GetPropertiesSortedByProtectionLev
}
}
return (locals, locals_internal, locals_private);
return (locals, locals_private);
}
internal virtual async Task<(JToken, Result)> EvaluateOnCallFrame(string id, string expression, bool expect_ok = true)
......
......@@ -449,12 +449,13 @@ private void AssertHasOnlyExpectedProperties(string[] expected_names, IEnumerabl
throw new XunitException($"missing or unexpected members found");
}
public static TheoryData<Dictionary<string, JObject>, Dictionary<string, JObject>, Dictionary<string, JObject>, string> GetDataForProtectionLevels()
public static TheoryData<Dictionary<string, JObject>, Dictionary<string, JObject>, string> GetDataForProtectionLevels()
{
var data = new TheoryData<Dictionary<string, JObject>, Dictionary<string, JObject>, Dictionary<string, JObject>, string>();
var data = new TheoryData<Dictionary<string, JObject>, Dictionary<string, JObject>, string>();
var public_props = new Dictionary<string, JObject>()
{
// --------- public ------------:
// own:
{"BaseBase_PropertyForHidingWithField", TNumber(210)},
{"Base_PropertyForOverridingWithProperty", TGetter("Base_PropertyForOverridingWithProperty", TDateTime(new DateTime(2020, 7, 6, 5, 4, 3)))},
......@@ -487,10 +488,8 @@ private void AssertHasOnlyExpectedProperties(string[] expected_names, IEnumerabl
{"BaseBase_AutoPropertyForHidingWithAutoProperty (BaseBaseClass2)", TString("BaseBase#BaseBase_AutoPropertyForHidingWithAutoProperty")},
{"BaseBase_PropertyForVHO (BaseBaseClass2)", TGetter("BaseBase_PropertyForVHO (BaseBaseClass2)", TString("BaseBase#BaseBase_PropertyForVHO"))},
{"BaseBase_AutoPropertyForVHO (BaseBaseClass2)", TString("BaseBase#BaseBase_AutoPropertyForVHO")},
};
var internal_protected_props = new Dictionary<string, JObject>(){
// ---- internal / protected ----:
// own:
{"BaseBase_AutoPropertyForHidingWithProperty", TGetter("BaseBase_AutoPropertyForHidingWithProperty", TString("Derived#BaseBase_AutoPropertyForHidingWithProperty"))},
{"Base_PropertyForOverridingWithAutoProperty", TDateTime(new DateTime(2022, 7, 6, 5, 4, 3))},
......@@ -510,20 +509,19 @@ private void AssertHasOnlyExpectedProperties(string[] expected_names, IEnumerabl
{"BaseBase_AutoPropertyForHidingWithProperty (BaseClass2)", TGetter("BaseBase_AutoPropertyForHidingWithProperty (BaseClass2)", TString("Base#BaseBase_AutoPropertyForHidingWithProperty"))},
{"BaseBase_PropertyForHidingWithAutoProperty", TString("Base#BaseBase_PropertyForHidingWithAutoProperty")},
};
data.Add(public_props, internal_protected_props, private_props, "DerivedClass2");
data.Add(public_props, private_props, "DerivedClass2");
// structure CloneableStruct:
public_props = new Dictionary<string, JObject>()
{
// own
// public
{"a", TNumber(4)},
{"DateTime", TGetter("DateTime")},
{"AutoStringProperty", TString("CloneableStruct#AutoStringProperty")},
{"FirstName", TGetter("FirstName")},
{"LastName", TGetter("LastName")}
};
internal_protected_props = new Dictionary<string, JObject>()
{
{"LastName", TGetter("LastName")},
// internal
{"b", TBool(true)}
};
......@@ -533,14 +531,14 @@ private void AssertHasOnlyExpectedProperties(string[] expected_names, IEnumerabl
{"_dateTime", TDateTime(new DateTime(2020, 7, 6, 5, 4, 3 + 3))},
{"_DTProp", TGetter("_DTProp")}
};
data.Add(public_props, internal_protected_props, private_props, "CloneableStruct");
data.Add(public_props, private_props, "CloneableStruct");
return data;
}
[ConditionalTheory(nameof(RunningOnChrome))]
[MemberData(nameof(GetDataForProtectionLevels))]
public async Task PropertiesSortedByProtectionLevel(
Dictionary<string, JObject> expectedPublic, Dictionary<string, JObject> expectedProtInter, Dictionary<string, JObject> expectedPriv, string entryMethod) =>
Dictionary<string, JObject> expectedPublicInternalAndProtected, Dictionary<string, JObject> expectedPriv, string entryMethod) =>
await CheckInspectLocalsAtBreakpointSite(
$"DebuggerTests.GetPropertiesTests.{entryMethod}", "InstanceMethod", 1, $"DebuggerTests.GetPropertiesTests.{entryMethod}.InstanceMethod",
$"window.setTimeout(function() {{ invoke_static_method ('[debugger-test] DebuggerTests.GetPropertiesTests.{entryMethod}:run'); }})",
......@@ -548,14 +546,12 @@ private void AssertHasOnlyExpectedProperties(string[] expected_names, IEnumerabl
{
var id = pause_location["callFrames"][0]["callFrameId"].Value<string>();
var (obj, _) = await EvaluateOnCallFrame(id, "this");
var (pub, internalAndProtected, priv) = await GetPropertiesSortedByProtectionLevels(obj["objectId"]?.Value<string>());
var (pubInternalAndProtected, priv) = await GetPropertiesSortedByProtectionLevels(obj["objectId"]?.Value<string>());
AssertHasOnlyExpectedProperties(expectedPublic.Keys.ToArray(), pub.Values<JObject>());
AssertHasOnlyExpectedProperties(expectedProtInter.Keys.ToArray(), internalAndProtected.Values<JObject>());
AssertHasOnlyExpectedProperties(expectedPublicInternalAndProtected.Keys.ToArray(), pubInternalAndProtected.Values<JObject>());
AssertHasOnlyExpectedProperties(expectedPriv.Keys.ToArray(), priv.Values<JObject>());
await CheckProps(pub, expectedPublic, "public");
await CheckProps(internalAndProtected, expectedProtInter, "internalAndProtected");
await CheckProps(pubInternalAndProtected, expectedPublicInternalAndProtected, "result");
await CheckProps(priv, expectedPriv, "private");
});
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册