Skip to content

Commit

Permalink
Add more asserts and ToStrings around the FakeProperty.Setter problem
Browse files Browse the repository at this point in the history
  • Loading branch information
exyi committed Oct 5, 2022
1 parent 18481ef commit 44a6aa7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions ICSharpCode.Decompiler/CSharp/CallBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,8 @@ public ExpressionWithResolveResult BuildCollectionInitializerExpression(OpCode c
public ExpressionWithResolveResult BuildDictionaryInitializerExpression(OpCode callOpCode, IMethod method,
InitializedObjectResolveResult target, IReadOnlyList<ILInstruction> indices, ILInstruction value = null)
{
if (method is null) throw new ArgumentNullException(nameof(method));

ExpectedTargetDetails expectedTargetDetails = new ExpectedTargetDetails { CallOpCode = callOpCode };

var callArguments = new List<ILInstruction>();
Expand Down
1 change: 1 addition & 0 deletions ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3340,6 +3340,7 @@ private ArrayInitializerExpression BuildArrayInitializerExpression(Block block,
{
var property = (IProperty)lastElement.Member;
Debug.Assert(property.IsIndexer);
Debug.Assert(property.Setter != null, $"Indexer property {property} has no setter");
elementsStack.Peek().Add(
new CallBuilder(this, typeSystem, settings)
.BuildDictionaryInitializerExpression(lastElement.OpCode, property.Setter, initObjRR, GetIndices(lastElement.Indices, indexVariables).ToList(), info.Values.Single())
Expand Down
10 changes: 10 additions & 0 deletions ICSharpCode.Decompiler/TypeSystem/Implementation/FakeMember.cs
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,16 @@ public override IMember Specialize(TypeParameterSubstitution substitution)
public bool IsIndexer { get; set; }
public bool ReturnTypeIsRefReadOnly => false;
public IReadOnlyList<IParameter> Parameters { get; set; }

public override string ToString() =>
"FakeProperty " + ReturnType + " " + DeclaringType.Name + "." + Name +
(Parameters.Count == 0
? ""
: "[" + string.Join(", ", Parameters) + "]") +
" { " +
(CanGet ? "get; " : "") +
(CanSet ? "set; " : "") +
"}";
}

sealed class FakeEvent : FakeMember, IEvent
Expand Down

0 comments on commit 44a6aa7

Please sign in to comment.