lijunle / Vsxmd

VS XML documentation -> Markdown syntax.
MIT License
215 stars 51 forks source link

No docs are generated, Output window says 'Object reference not set to an instance of an object.' #86

Closed astrohart closed 3 years ago

astrohart commented 3 years ago

I am utilizing VS 2019 Community, latest update. Last night, Vsxmd was working fine with the configuration below. Now, it will not create a .md documentation file all of a sudden.

My packages.config file says:

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="Vsxmd" version="1.4.5" targetFramework="net48" developmentDependency="true" />
</packages>

My .csproj is:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
  <PropertyGroup>
    <ApplicationIcon>1382_cogs.ico</ApplicationIcon>
    <TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
    <TargetFrameworkProfile />
    <ProjectGuid>{84C1F71A-AAA4-4A08-9728-19E710965E4D}</ProjectGuid>
    <NuGetPackageImportStamp>
    </NuGetPackageImportStamp>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
    <DebugSymbols>true</DebugSymbols>
    <OutputPath>bin\x64\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <DebugType>full</DebugType>
    <PlatformTarget>x64</PlatformTarget>
    <LangVersion>7.3</LangVersion>
    <ErrorReport>prompt</ErrorReport>
    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
    <Prefer32Bit>false</Prefer32Bit>
    <DocumentationFile>bin\x64\Debug\MyProject.xml</DocumentationFile>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
    <OutputPath>bin\x64\Release\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <Optimize>true</Optimize>
    <DebugType>pdbonly</DebugType>
    <PlatformTarget>x64</PlatformTarget>
    <LangVersion>7.3</LangVersion>
    <ErrorReport>prompt</ErrorReport>
    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
    <Prefer32Bit>false</Prefer32Bit>
    <DocumentationFile>bin\x64\Release\MyProject.xml</DocumentationFile>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
    <DebugSymbols>true</DebugSymbols>
    <OutputPath>bin\x86\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <DebugType>full</DebugType>
    <PlatformTarget>x86</PlatformTarget>
    <LangVersion>7.3</LangVersion>
    <ErrorReport>prompt</ErrorReport>
    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
    <Prefer32Bit>false</Prefer32Bit>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
    <OutputPath>bin\x86\Release\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <Optimize>true</Optimize>
    <DebugType>pdbonly</DebugType>
    <PlatformTarget>x86</PlatformTarget>
    <LangVersion>7.3</LangVersion>
    <ErrorReport>prompt</ErrorReport>
    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
    <Prefer32Bit>false</Prefer32Bit>
  </PropertyGroup>
  <PropertyGroup>
    <OutputType>Library</OutputType>
  </PropertyGroup>
  <PropertyGroup>
    <StartupObject />
  </PropertyGroup>
  <PropertyGroup>
    <AssemblyName>MyProject</AssemblyName>
  </PropertyGroup>
  <PropertyGroup>
    <RootNamespace>MyProject</RootNamespace>
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="System" />
    <Reference Include="System.Core" />
  </ItemGroup>
  <ItemGroup>
    <Compile Include="DeviceFoundEventArgs.cs" />
    <Compile Include="DeviceFoundEventHandler.cs" />
    <Compile Include="Properties\AssemblyInfo.cs" />
    <Compile Include="Properties\Resources.Designer.cs">
      <AutoGen>True</AutoGen>
      <DesignTime>True</DesignTime>
      <DependentUpon>Resources.resx</DependentUpon>
    </Compile>
  </ItemGroup>
  <ItemGroup>
    <EmbeddedResource Include="Properties\Resources.resx">
      <Generator>ResXFileCodeGenerator</Generator>
      <LastGenOutput>Resources.Designer.cs</LastGenOutput>
    </EmbeddedResource>
  </ItemGroup>
  <ItemGroup>
    <Content Include="1382_cogs.ico" />
  </ItemGroup>
  <ItemGroup>
    <None Include="packages.config" />
    <None Include="MyProject.md" />
  </ItemGroup>
  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
  <PropertyGroup>
    <PreBuildEvent>if exist "$(TargetDir)$(ProjectName).md" (
    if exist "$(ProjectDir)$(ProjectName).md" (
        erase /F /Q "$(ProjectDir)$(ProjectName).md"
    )
    copy /Y "$(TargetDir)$(ProjectName).md" "$(ProjectDir)"
)
exit /b 0</PreBuildEvent>
  </PropertyGroup>
  <PropertyGroup>
    <PostBuildEvent>if "$(ConfigurationName)"=="Release" (
    erase /F /S /Q "$(TargetDir)*.pdb"
    erase /F /S /Q "$(TargetDir)*.config"
    erase /F /S /Q "$(TargetDir)*.vshost.exe"
    attrib +r "$(TargetDir)$(ProjectName).xml"
    attrib +r "$(TargetDir)$(ProjectName).md"
    erase /F /S /Q "$(TargetDir)*.xml"
    attrib -r "$(TargetDir)$(ProjectName).xml"
    attrib -r "$(TargetDir)$(ProjectName).md"
)
exit /b 0</PostBuildEvent>
  </PropertyGroup>
  <Import Project="..\packages\Vsxmd.1.4.5\build\Vsxmd.targets" Condition="Exists('..\packages\Vsxmd.1.4.5\build\Vsxmd.targets')" />
  <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
    <PropertyGroup>
      <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them.  For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
    </PropertyGroup>
    <Error Condition="!Exists('..\packages\Vsxmd.1.4.5\build\Vsxmd.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Vsxmd.1.4.5\build\Vsxmd.targets'))" />
  </Target>
</Project>

I have done a Restore NuGet Packages in Solution on my .sln file in Solution Explorer.

As you can see, there is a line <None Include="MyProject.md" />. And, indeed, when zero C# classes or interfaces (except for the one generated by the Resources.resx file in Resources.Designer.cs) are in the file, the MyProject.md is spat out just perfectly. However, once I paste in some source files for C# event args class and a delegate, then I get an error in the Output window.

My C# class and delegate are standard *EventArgs and a public delegate void MyEvent(object sender, MyEventArgs e); with well-formed XML docs and cross-references. My project builds perfectly.

The project builds just fine but then there is an error Object reference not set to an instance of an object. in the Output window, which I assume is coming from Vsxmd. I assume this, because if I go into NuGet Package Manager and Uninstall the Vsxmd package, the project still builds as previously, but the message Object reference not set to an instance of an object. does not appear anymore. Therefore, my assumption is that when Vsxmd is installed, it is causing the Object reference not set to an instance of an object. error.

Here's the text of my Output window when Vsxmd is installed:

1>------ Build started: Project: MyProject, Configuration: Debug x64 ------
1>  MyProject -> D:\Users\StrayCat\source\repos\mycoolgithub\MyProject\MyProject\bin\x64\Debug\MyProject.dll
1>  Object reference not set to an instance of an object.
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

Names of my username on the computer and the github name and my project's name have been changed to protect the guilty ;-) or innocent :-D.

astrohart commented 3 years ago

Never mind. I think I found the issue. I had an XML documentation tag that said <param product="sender">Reference to the instance of the object that raised the event.</param>.

I found this out by erasing my .cs files and adding things in a bit at a time and building/rebuilding in between to see when the Object reference not set to the instance of an object message would show. Obviously, it should be <param name="sender">...</param> not <param product="sender">...</param>.