EWSoftware / SHFB

Sandcastle Help File Builder (SHFB). A standalone GUI, Visual Studio integration package, and MSBuild tasks providing full configuration and extensibility for building help files with the Sandcastle tools.
Other
2.19k stars 369 forks source link

MRefBuilder: No members in the template matched the parameters of the specialization. This is not possible but apparently it happened #983

Closed WolfgangHG closed 1 year ago

WolfgangHG commented 1 year ago

This error happens after updating to 2023.3.4.0:

MRefBuilder : error : An unexpected error occurred trying to execute the MRefBuilder MSBuild task: System.InvalidOperationException: com.hg.tools.HGSettingsAccessBase`1<System.Collections.Specialized.NameValueCollection> [E:\Projekte\Tools\DEV\ToolsDataDoc\Help\Working\GenerateRefInfo-7ebe259d-4540-45ff-8642-104f6614ff1f.proj]
MRefBuilder : error : com.hg.tools.HGSettingsAccessBase`1<System.Collections.Specialized.NameValueCollection>.GetEnumValue(System.Collections.Specialized.NameValueCollection,System.String,type parameter.TEnum,com.hg.tools.HGSettingsAccessBase`1<System.Collections.Specialized.NameValueCollection>+TEnum@) [E:\Projekte\Tools\DEV\ToolsDataDoc\Help\Working\GenerateRefInfo-7ebe259d-4540-45ff-8642-104f6614ff1f.proj]
MRefBuilder : error : No members in the template matched the parameters of the specialization.  This is not possible but apparently it happened. [E:\Projekte\Tools\DEV\ToolsDataDoc\Help\Working\GenerateRefInfo-7ebe259d-4540-45ff-8642-104f6614ff1f.proj]
MRefBuilder : error :    bei Sandcastle.Tools.Reflection.ReflectionUtilities.GetTemplateMember(Member member) [E:\Projekte\Tools\DEV\ToolsDataDoc\Help\Working\GenerateRefInfo-7ebe259d-4540-45ff-8642-104f6614ff1f.proj]
MRefBuilder : error :    bei Sandcastle.Tools.ManagedReflectionWriter.WriteTypeElements(TypeNode type) [E:\Projekte\Tools\DEV\ToolsDataDoc\Help\Working\GenerateRefInfo-7ebe259d-4540-45ff-8642-104f6614ff1f.proj]
MRefBuilder : error :    bei Sandcastle.Tools.ManagedReflectionWriter.WriteType(TypeNode type) [E:\Projekte\Tools\DEV\ToolsDataDoc\Help\Working\GenerateRefInfo-7ebe259d-4540-45ff-8642-104f6614ff1f.proj]
MRefBuilder : error :    bei Sandcastle.Tools.ManagedReflectionWriter.VisitType(TypeNode type) [E:\Projekte\Tools\DEV\ToolsDataDoc\Help\Working\GenerateRefInfo-7ebe259d-4540-45ff-8642-104f6614ff1f.proj]
MRefBuilder : error :    bei Sandcastle.Tools.Reflection.ApiVisitor.VisitTypes(TypeNodeList types) [E:\Projekte\Tools\DEV\ToolsDataDoc\Help\Working\GenerateRefInfo-7ebe259d-4540-45ff-8642-104f6614ff1f.proj]
MRefBuilder : error :    bei Sandcastle.Tools.Reflection.ApiVisitor.VisitNamespaces(NamespaceList spaces) [E:\Projekte\Tools\DEV\ToolsDataDoc\Help\Working\GenerateRefInfo-7ebe259d-4540-45ff-8642-104f6614ff1f.proj]
MRefBuilder : error :    bei Sandcastle.Tools.ManagedReflectionWriter.VisitNamespaces(NamespaceList spaces) [E:\Projekte\Tools\DEV\ToolsDataDoc\Help\Working\GenerateRefInfo-7ebe259d-4540-45ff-8642-104f6614ff1f.proj]
MRefBuilder : error :    bei Sandcastle.Tools.Reflection.ApiVisitor.VisitApis() [E:\Projekte\Tools\DEV\ToolsDataDoc\Help\Working\GenerateRefInfo-7ebe259d-4540-45ff-8642-104f6614ff1f.proj]
MRefBuilder : error :    bei Sandcastle.Tools.MSBuild.MRefBuilder.GenerateReflectionInformation() [E:\Projekte\Tools\DEV\ToolsDataDoc\Help\Working\GenerateRefInfo-7ebe259d-4540-45ff-8642-104f6614ff1f.proj]
MRefBuilder : error :    bei Sandcastle.Tools.MSBuild.MRefBuilder.Execute() [E:\Projekte\Tools\DEV\ToolsDataDoc\Help\Working\GenerateRefInfo-7ebe259d-4540-45ff-8642-104f6614ff1f.proj]

The source file snippets are those:

  /// <summary>
  /// ...
  /// </summary>
  /// <typeparam name="T">...</typeparam>
  /// <remarks>
  /// ....
  /// </remarks>
  public abstract class HGSettingsAccessBase<T>
    where T : class
  {
    ...

    /// <summary>
    /// ...
    /// </summary>
    /// <param name="_settings">....</param>
    /// <param name="_strValueName">...</param>
    /// <param name="_enumDefaultValue">...</param>
    /// <param name="_enumValue">...</param>
    /// <typeparam name="TEnum">...</typeparam>
    /// <returns>...</returns>
    public HGSettingsStatus GetEnumValue<TEnum>(T _settings, string _strValueName, TEnum _enumDefaultValue, out TEnum _enumValue)
      where TEnum : Enum
    {
      ...
    }

And an implementing subclass that seems to trigger the error is:

  /// <summary>
  /// ...
  /// </summary>
  /// <remarks>
  /// ...
  /// </remarks>
  public class HGAppSettings : HGSettingsAccessBase<NameValueCollection>
  {
     ...

    /// <summary>
    /// ...
    /// </summary>
    /// <param name="_settings">....</param>
    /// <param name="_strValueName">....</param>
    /// <param name="_enumDefaultValue">....</param>
    /// <param name="_enumValue">...</param>
    /// <typeparam name="TEnum">...</typeparam>
    /// <returns>...</returns>
    public static HGSettingsStatus GetEnum<TEnum>(NameValueCollection _settings, string _strValueName, TEnum _enumDefaultValue, out TEnum _enumValue)
      where TEnum : Enum
    {
      return HGAppSettings.UniqueInstance.GetEnumValue<TEnum>(_settings, _strValueName, _enumDefaultValue, out _enumValue);
    }

Is this enough information to identify the issue? Or do you need a full project?

EWSoftware commented 1 year ago

I'm unable to duplicate the issue with the snippets above. Can you provide a working example I can use to duplicate the issue?

WolfgangHG commented 1 year ago

I will try to do so - but it might not happen before next weekend.

WolfgangHG commented 1 year ago

Here is the sample.

Sandcastle_Issue983.zip

The zip contains the output of the last failing build, including the error message in "LastBuild.log".

I copied the project file from the solution where the error occurs and updated it to match this sample. So, it is a rather old project file that was updated over the years.

WolfgangHG commented 1 year ago

Was this introduced by the change for #968 ?

EWSoftware commented 1 year ago

I'm not sure but I don't think so. This case has a template parameter on the method that didn't appear in the parameter list which it hasn't considered before. I added a case to check it as well for a match to fix it. If it was working in a prior release, it may have slipped through but perhaps showed an incorrect match.