This is a migrated thread and some comments may be shown as answers.

Just Decompile Errors with ASP.Net Core 3.1

1 Answer 82 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Cyrus
Top achievements
Rank 1
Cyrus asked on 14 Jul 2020, 11:33 PM

Hi,

I lost the source code of an ASP.Net Core project due to a corrupted operating system and HP backup recovery falsely stating that it backs up content of the documents folder without mentioning that only certain file types are backed up. I used DotPeek to recover a lot of code but some classes could not be decompiled. Those same classes are also having problems with Just Decompile. Usually these classes use a lot of lambda expressions.

Here is an example of a customized Login model that returns an error saying "JustDecompile was unable to locate the assembly where attribute parameters types are defined. Generating parameters values is impossible." This error was proceeded by a prompt when decompiling that asked for the location of some assembly, but I hit skip and when opening the LoginModel I am no longer prompted to give the location. 

When I copy the output into Visual Studio 2019 I get a bunch of errors for things like base.get_HttpContext() or base.get_Url() which were not in the source code. DotPeek made the same mistake so I would have to go and manually change those to whatever method I was using to get the current HttpContext, Url, RouteData, etc.

Here is the output:

using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Identity.UI.Services;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.ModelBinding;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.CSharp.RuntimeBinder;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Diagnostics;
using System.Linq;
using System.Net.Http;
using System.Runtime.CompilerServices;
using System.Text.Encodings.Web;
using System.Threading.Tasks;

namespace PostAlmostAnything.Areas.Identity.Pages.Account
{
    [AllowAnonymous]
    public class LoginModel : PageModel
    {
        private readonly UserManager<IdentityUser> _userManager;

        private readonly SignInManager<IdentityUser> _signInManager;

        private readonly ILogger<LoginModel> _logger;

        private readonly IEmailSender _emailSender;

        private readonly IConfiguration configuration;

        private readonly IHttpClientFactory _httpClientFactory;

        [TempData]
        public string ErrorMessage
        {
            get;
            set;
        }

        public IList<AuthenticationScheme> ExternalLogins
        {
            get;
            set;
        }

        [BindProperty]
        public LoginModel.InputModel Input
        {
            get;
            set;
        }

        public string ReturnUrl
        {
            get;
            set;
        }

        public LoginModel(SignInManager<IdentityUser> signInManager, ILogger<LoginModel> logger, UserManager<IdentityUser> userManager, IEmailSender emailSender, IConfiguration configuration, IHttpClientFactory httpClientFactory)
        {
            this._userManager = userManager;
            this._signInManager = signInManager;
            this._emailSender = emailSender;
            this._logger = logger;
            this.configuration = configuration;
            this._httpClientFactory = httpClientFactory;
        }

        public async Task OnGetAsync(string returnUrl = null)
        {
            if (!string.IsNullOrEmpty(this.ErrorMessage))
            {
                base.get_ModelState().AddModelError(string.Empty, this.ErrorMessage);
            }
            string str = returnUrl;
            if (str == null)
            {
                str = base.get_Url().Content("~/");
            }
            returnUrl = str;
            await AuthenticationHttpContextExtensions.SignOutAsync(base.get_HttpContext(), IdentityConstants.ExternalScheme);
            IEnumerable<AuthenticationScheme> externalAuthenticationSchemesAsync = await this._signInManager.GetExternalAuthenticationSchemesAsync();
            this.ExternalLogins = Enumerable.ToList<AuthenticationScheme>(externalAuthenticationSchemesAsync);
            externalAuthenticationSchemesAsync = null;
            this.ReturnUrl = returnUrl;
        }

        public async Task<IActionResult> OnPostAsync(string returnUrl = null)
        {
            LoginModel.<OnPostAsync>d__25 variable = null;
            AsyncTaskMethodBuilder<IActionResult> asyncTaskMethodBuilder = AsyncTaskMethodBuilder<IActionResult>.Create();
            asyncTaskMethodBuilder.Start<LoginModel.<OnPostAsync>d__25>(ref variable);
            return asyncTaskMethodBuilder.get_Task();
        }

        public async Task<IActionResult> OnPostSendVerificationEmailAsync()
        {
            IActionResult actionResult;
            if (base.get_ModelState().get_IsValid())
            {
                IdentityUser identityUser = await this._userManager.FindByNameAsync(this.Input.UserName);
                IdentityUser identityUser1 = identityUser;
                identityUser = null;
                if (identityUser1 == null)
                {
                    base.get_ModelState().AddModelError(string.Empty, "Verification email sent. Please check your email.");
                }
                string userIdAsync = await this._userManager.GetUserIdAsync(identityUser1);
                string str = userIdAsync;
                userIdAsync = null;
                string emailAsync = await this._userManager.GetEmailAsync(identityUser1);
                string str1 = emailAsync;
                emailAsync = null;
                string str2 = await this._userManager.GenerateEmailConfirmationTokenAsync(identityUser1);
                string str3 = str2;
                str2 = null;
                string str4 = UrlHelperExtensions.Page(base.get_Url(), "/Account/ConfirmEmail", null, new { userId = str, code = str3 }, base.get_Request().get_Scheme());
                await this._emailSender.SendEmailAsync(str1, "Confirm your email", string.Concat("Please confirm your account by <a href='", HtmlEncoder.get_Default().Encode(str4), "'>clicking here</a>."));
                base.get_ModelState().AddModelError(string.Empty, "Verification email sent. Please check your email.");
                actionResult = this.Page();
            }
            else
            {
                actionResult = this.Page();
            }
            return actionResult;
        }

        public class InputModel
        {
            [DataType(,)]    // JustDecompile was unable to locate the assembly where attribute parameters types are defined. Generating parameters values is impossible.
            [Required]
            public string Password
            {
                get;
                set;
            }

            [Display(Name="Remember me?")]
            public bool RememberMe
            {
                get;
                set;
            }

            [Display(Name="Login Name")]
            [Required]
            public string UserName
            {
                get;
                set;
            }

            public InputModel()
            {
            }
        }
    }
}

1 Answer, 1 is accepted

Sort by
0
Nick Iliev
Telerik team
answered on 17 Jul 2020, 06:02 AM

Hello Cyrus,

 

Would it be possible to share a test project that reproduces the issue (and creates similar output)? I will test the issue on my side and post here once I have more insights.

 

Regards,
Nick Iliev
Progress Telerik

Tags
General Discussions
Asked by
Cyrus
Top achievements
Rank 1
Answers by
Nick Iliev
Telerik team
Share this question
or