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

Error BE0065: An error occurred while attempting to transform the reflection data to a topic. When Extensions Methods to Enum. #1050

Closed jenergm closed 3 months ago

jenergm commented 7 months ago

Hi there,

When matching Extensions Methods to Enum throws an Error BE0065: An error occurred while attempting to transform the reflection data to a topic. The error message was: System.NullReferenceException

/// <summary>
/// Page size enum options
/// </summary>
public enum PageSize
{
    /// <summary>
    /// A4 size 21cm x 29.7cm.
    /// </summary>
    A4,
    /// <summary>
    /// Letter size 21.59cm x 27.94cm
    /// </summary>
    Letter,
    /// <summary>
    /// Office size 21.59cm x 35.56cm
    /// </summary>
    Office
}
/// <summary>
/// Extension methods for Page Size helper.
/// </summary>
public static class PageSizeExtension
{
    /// <summary>
    /// Get the size for a pageSize enum.
    /// </summary>
    /// <param name="pageSize">The pageSize enum item at issue.</param>
    /// <returns>The size (width and height) of the page at issue.</returns>
    public static Size Size (this PageSize pageSize)
    {
        switch (pageSize)
        {
            case PageSize.A4: return new Size() { Width = "21cm", Height = "29.7cm" };
            case PageSize.Letter: return new Size() { Width = "21.59cm", Height = "27.94cm" };
            case PageSize.Office: return new Size() { Width = "21.59cm", Height = "35.56cm" };
            default : return null;
        }
    }
}

I've edited API Filter in Project Properties -> Visibility -> Edit API Filter to disable PageSizeExtension class and bypass the error. But I know it's not the solution even a workarround. But I needed build the project.

That is about: Sandcastle Help File Builder and Tools Version: 2024.2.18.0

EWSoftware commented 5 months ago

I can't duplicate the issue with the snippets above. The Size class is missing so it may be related to that. Can you attach an example that I can build that reproduces the error?

jenergm commented 5 months ago

Hello, Size class is:

/// <summary>
/// Size used by report page.
/// </summary>
public class Size
{
    /// <summary>
    /// The report page width in centimeters. Example: &quot;21cm&quot;.
    /// </summary>
    public string Width { get; set; }
    /// <summary>
    /// The report page height in centimeters. Example: &quot;29.7cm&quot;.
    /// </summary>
    public string Height { get; set; }
}

An example of PageSizeExtension is:

/// <summary>
/// Configuration of the report's page.
/// </summary>
public class ReportPageDefinition
{
    /// <summary>
    /// The report page size.
    /// </summary>
    public PageSize PageSize { get; set; }

    /// <summary>
    /// The report page orientation. Portrait or Landscape.
    /// </summary>
    public PageOrientation PageOrientation { get; set; }

    /// <summary>
    /// The report page width according page orientation and size.
    /// </summary>
    /// <returns>The report page width in centimeters. Example: &quot;21cm&quot;.</returns>
    public string PageWidth()
    {
        if (PageOrientation == Reporting.PageOrientation.Portrait)
            return this.PageSize.Size().Width;
        else
            return this.PageSize.Size().Height;
    }

    /// <summary>
    /// The report page height according page orientation and size.
    /// </summary>
    /// <returns>The report page height in centimeters. Example: &quot;29.7cm&quot;.</returns>
    public string PageHeight()
    {
        if (PageOrientation == Reporting.PageOrientation.Portrait)
            return this.PageSize.Size().Height;
        else
            return this.PageSize.Size().Width;
    }
}
EWSoftware commented 5 months ago

It still works so it may be something unique to your project. As requested above, can you attach something I can build to try and duplicate the error you are seeing?

EWSoftware commented 3 months ago

The fix for #1071 should also correct this issue.