Skip to content

Commit

Permalink
added some settings validation for better error message (closes #154)
Browse files Browse the repository at this point in the history
  • Loading branch information
Doraku committed Nov 1, 2024
1 parent 8d1fee3 commit 361844c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions documentation/NEXT_RELEASENOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
- added ExcludeGenerator to exclude DocItem from the documentation generation based on regex (closes #160)
- list code and note elements now display a placeholder value `...` when displayed as a single line
- added DirectoryName IFileNameFactory implementation (closes #104)
- added some settings validation for better error message (closes #154)

## Bug fixes

Expand Down
2 changes: 2 additions & 0 deletions source/DefaultDocumentation.Common/Generator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ private Generator(Target loggerTarget, IRawSettings settings)
GetSetting<string>(nameof(settings.LinksBaseUrl)),
GetSetting<string[]>(nameof(settings.ExternLinksFilePaths)));

resolvedSettings.Validate();

AppDomain.CurrentDomain.AssemblyResolve += (object sender, ResolveEventArgs args) =>
{
AssemblyName assemblyName = new(args.Name);
Expand Down
13 changes: 13 additions & 0 deletions source/DefaultDocumentation.Common/Internal/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,19 @@ private static IEnumerable<string> GetFilePaths(string filePath)
}
}

public void Validate()
{
if (!AssemblyFile.Exists)
{
throw new FileNotFoundException("The assembly file does not exist", AssemblyFile.FullName);
}

if (!DocumentationFile.Exists)
{
throw new FileNotFoundException("The xml documentation file does not exist, ensure you activated the \"GenerateDocumentationFile\" property of the project", DocumentationFile.FullName);
}
}

#region ISettings

public ILogger Logger { get; }
Expand Down

0 comments on commit 361844c

Please sign in to comment.