ASP.net Core中的UserManager <TUser>类中没有可见的实现详细信息

时间:2019-11-01 15:22:50

标签: c# asp.net-core-mvc

对于ASP.NET核心我还是一个新手,我正在探索ASP.NET核心身份库,以查看代码在屏幕后的工作方式。

我已经知道UserManager类负责通过调用以下方法来创建用户:CreateAsync(TUser user);。

但是,当我通过选择Visual Studio中的UserManager类并按F12(转到“定义”)来检查UserManager类时,在CreateAsync方法中看不到任何实现代码。

它看起来像这样:

 componentDidMount() {
    AudioRecorder.requestAuthorization().then(isAuthorised => {
      this.setState({hasPermission: isAuthorised});
      AudioRecorder.onFinished = data => {
        this.props.setData(data);
      };
    });
  }

这是文件的开头:

        //
    // Summary:
    //     Creates the specified user in the backing store with no password, as an asynchronous
    //     operation.
    //
    // Parameters:
    //   user:
    //     The user to create.
    //
    // Returns:
    //     The System.Threading.Tasks.Task that represents the asynchronous operation, containing
    //     the Microsoft.AspNetCore.Identity.IdentityResult of the operation.
    [DebuggerStepThrough]
    public virtual Task<IdentityResult> CreateAsync(TUser user);

当我转到GitHub时,我可以看到UserManager.cs中的CreateAsync确实具有这样的实现代码:

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Security.Claims;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;

namespace Microsoft.AspNetCore.Identity
{
    //
    // Summary:
    //     Provides the APIs for managing user in a persistence store.
    //
    // Type parameters:
    //   TUser:
    //     The type encapsulating a user.
    public class UserManager<TUser> : IDisposable where TUser : class

很明显,我正在查看两个不同的文件。

有人可以告诉我在Visual Studio中可以找到CreateAsync方法的实现吗?

1 个答案:

答案 0 :(得分:0)

Visual Studio不提供获取解决方案中引用的外部程序集(.dll)内容的可能性。

您将需要像dotPeek这样的反编译器才能实现所需的功能:https://www.jetbrains.com/decompiler/

在您的案例中,另一个有用的工具是Resharper和JetBrains的工具。 dotPeek是免费的,Resharper具有试用版。