Skip to content

Commit

Permalink
Add support for ref types in the C# decompiler
Browse files Browse the repository at this point in the history
  • Loading branch information
ElektroKill committed Jun 25, 2023
1 parent 673588b commit fde84b3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// Copyright (c) 2011 AlphaSierraPapa for the SharpDevelop Team
//
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
Expand Down Expand Up @@ -250,7 +250,7 @@ void RunTransformsAndGenerateCode(ref BuilderState state, IDecompilerOutput outp
astBuilder.GenerateCode(output);
}

internal static void AddXmlDocumentation(ref BuilderState state, DecompilerSettings settings, AstBuilder astBuilder) {
internal static void AddXmlDocumentation(ref BuilderState state, DecompilerSettings settings, AstBuilder astBuilder) {
if (settings.ShowXmlDocumentation) {
var module = state.AstBuilder.Context.CurrentModule;
var hasXmlDocFileTmp = state.State.HasXmlDocFile(module);
Expand Down Expand Up @@ -358,8 +358,8 @@ void TypeToString(IDecompilerOutput output, ConvertTypeOptions options, ITypeDef
AstType astType = AstBuilder.ConvertType(type, new StringBuilder(), typeAttributes, options);

if (WriteRefIfByRef(output, type.TryGetByRefSig(), typeAttributes as ParamDef)) {
if (astType is ComposedType && ((ComposedType)astType).PointerRank > 0)
((ComposedType)astType).PointerRank--;
if (astType is ComposedType composedType && composedType.HasRefSpecifier)
composedType.HasRefSpecifier = false;
}

var ctx = new DecompilerContext(langSettings.Settings.SettingsVersion, type.Module, MetadataTextColorProvider);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,8 @@ void TypeToString(IDecompilerOutput output, ConvertTypeOptions options, ITypeDef
if (type.TryGetByRefSig() is not null) {
output.Write("ByRef", BoxedTextColor.Keyword);
output.Write(" ", BoxedTextColor.Text);
if (astType is ICSharpCode.NRefactory.CSharp.ComposedType && ((ICSharpCode.NRefactory.CSharp.ComposedType)astType).PointerRank > 0)
((ICSharpCode.NRefactory.CSharp.ComposedType)astType).PointerRank--;
if (astType is ComposedType composedType && composedType.HasRefSpecifier)
composedType.HasRefSpecifier = false;
}

var vbAstType = astType.AcceptVisitor(converter, null);
Expand Down

0 comments on commit fde84b3

Please sign in to comment.