Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,33 @@
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<!-- Temporarily ignore warnings from dotnet target framework being out of support. When I decide to stop supporting older frameworks I need to remove this setting. For more info see https://andrewlock.net/fixing-build-warning-netsdk1138-when-building-end-of-life-projects-with-dotnet-5/ -->
<CheckEolTargetFramework>false</CheckEolTargetFramework>
<!--
GenerateDocumentationFile is something I wanted enabled for the projects under /src that produce the NuGet packages.
For tests I thought I didn't need this enabled but without it I won't get warnings about 'unused usings' (IDE0005)
when building with the dotnet CLI, I'll only get them when using Visual Studio or when running dotnet format.

For more info see:
- Compiler does not report unused imports when XML doc comments are disabled: https://github.com/dotnet/roslyn/issues/41640
- And this comment for the first workaround presented: https://github.com/dotnet/roslyn/issues/41640#issuecomment-985780130

NOTE:
1) Even if GenerateDocumentationFile is not required anymore to get IDE0005 to work via the dotnet CLI, I found that I might still
want to have GenerateDocumentationFile enabled even for my test projects. This is because I've chosen to use to add a summary documentation
tag to all my tests to explain what they do and by enabling GenerateDocumentationFile I "seem" get some extra checks on what I write on
those summary tags. For instance, on build I get warned if I have incorrect cref values.
When reviewing if I still need GenerateDocumentationFile for test projects I should test having an invalid cref and see if it I get
warnings on build.

2) Hopefully, when https://github.com/dotnet/roslyn/issues/41640 gets closed, I can tidy up this huge comment block

3) Some of the proposed fixes also add some exclusions to NoWarn like: <NoWarn>$(NoWarn);CS1573;CS1591;CS1712</NoWarn>
but I've found I didn't need them, yet at least.

CS1573: Parameter 'parameter' has no matching param tag in the XML comment for 'parameter' (but other parameters do)
CS1591: Missing XML comment for publicly visible type or member 'Type_or_Member'
CS1712: Type parameter 'type_parameter' has no matching typeparam tag in the XML comment on 'type_or_member' (but other type parameters do)
-->
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public class AddTestConfigurationHostTests
/// <summary>
/// Tests that <see cref="Host.CreateDefaultBuilder()"/> adds two <see cref="JsonConfigurationProvider"/>
/// to the app configuration.
/// This test serves as a control test because all the tests use the <see cref="WebHost.CreateDefaultBuilder()"/> as a way
/// This test serves as a control test because all the tests use the <see cref="Host.CreateDefaultBuilder()"/> as a way
/// to setup a <see cref="IWebHost"/> with several <see cref="ConfigurationProvider"/> and at least two <see cref="JsonConfigurationProvider"/>.
/// If this changes in the future then I could start having false positives on the other tests.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,24 @@ namespace DotNet.Sdk.Extensions.Testing.Tests.Configuration;
[Trait("Category", XUnitCategories.Configuration)]
public class AddTestConfigurationWebHostTests
{
// On the below summary I'm not using a <see cref=""/> tag for WebHost.CreateDefaultBuilder()
// because the static WebHost exists on both Microsoft.AspNetCore and Microsoft.AspNetCore.Hosting
// and I have both of then as global usings.
// Now in terms of code there's no clash and need to use full namespaces to disambiguate because
// the Microsoft.AspNetCore.Hosting.WebHost is internal and Microsoft.AspNetCore.WebHost is public,
// so it always picks the public one.
//
// HOWEVER, in code comments you can reference internal types so there's no way to know which one should
// be used without doing <see cref="Microsoft.AspNetCore.WebHost.CreateDefaultBuilder()"/>.
// The problem occurs when I run dotnet format and it says that I should remove Microsoft.AspNetCore from the
// cref attribute because it sees it on the global usings.
//
// For now I'm working around this problem by NOT using cref for this case.

/// <summary>
/// Tests that <see cref="WebHost.CreateDefaultBuilder()"/> adds two <see cref="JsonConfigurationProvider"/>
/// Tests that WebHost.CreateDefaultBuilder() adds two <see cref="JsonConfigurationProvider"/>
/// to the app configuration.
/// This test serves as a control test because all the tests use the <see cref="WebHost.CreateDefaultBuilder()"/> as a way
/// This test serves as a control test because all the tests use the WebHost.CreateDefaultBuilder() as a way
/// to setup a <see cref="IWebHost"/> with several <see cref="ConfigurationProvider"/> and at least two <see cref="JsonConfigurationProvider"/>.
/// If this changes in the future then I could start having false positives on the other tests.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public void Where2ValidateArguments()
}

/// <summary>
/// Validates the arguments for the <see cref="HttpResponseMessageMockBuilder.RespondWith(HttpResponseMessage)"/> method.
/// Validates the arguments for the <see cref="HttpResponseMessageMockBuilder.RespondWith(Func{HttpResponseMessage})"/> method.
/// </summary>
[Fact]
public void Respond1WithValidateArguments()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public async Task RepliesAsConfigured2()
/// In linux this test fails with error:
/// System.Net.Http.HttpRequestException : The SSL connection could not be established, see inner exception.
/// because dev certificate does not exist
/// For more info on how to resolve this issue see: https://docs.microsoft.com/en-us/aspnet/core/security/enforcing-ssl?view=aspnetcore-5.0&tabs=visual-studio#ssl-linux.
/// For more info on how to resolve this issue see: https://docs.microsoft.com/en-us/aspnet/core/security/enforcing-ssl#ssl-linux.
/// </remarks>
[Fact]
public async Task RepliesAsConfigured()
Expand Down