Skip to content

Conversation

@Shane32
Copy link
Member

@Shane32 Shane32 commented Aug 16, 2022

On NuGet.org, the readme file is not appearing. This is because the PackageReadmeFile did not get set while building. This is because the condition IsPackable == true does not work if IsPackable is not explicitly set, even though when it is not set, it is implied to be true for the purposes of packing and within ItemGroups. This also caused the analysis to be disabled.

The analysis mode revealed that some xml comments on some old code was missing.

I ran the pack locally and examined the output to be sure it built correctly this time.

It is not critical to release 7.0.1, as there are no breaking changes and the 7.0.0 code should work just fine. Nevertheless, we can release 7.0.1 if you think we should @sungam3r , before everyone downloads it. Or, we could wait a week or two to see if there are any other issues that need to be addressed.

@Shane32 Shane32 self-assigned this Aug 16, 2022
@Shane32 Shane32 changed the title Fix packing and analysis recommendations Fix packing readme and analysis recommendations Aug 16, 2022
@Shane32 Shane32 added this to the 7.0.1 milestone Aug 16, 2022
@Shane32 Shane32 requested a review from sungam3r August 16, 2022 13:13
@sungam3r
Copy link
Member

sungam3r commented Aug 17, 2022

Sad news. Does this mean that other projects also have this problem? I see readme in graphql-dotner but not parser 🤔 . Looks a bit weird. How about just move property out of Condition?

  <PropertyGroup>
    <PackageReadmeFile>README.md</PackageReadmeFile>
  </PropertyGroup>

The same for AnalysisMode. I understand it requires a bit more work but it should not be difficult. I propose to add CA1707 into NoWarn in Tests.props . After that I see only ~60 issues to fix 😉 . I think this is better than jumping over different order of conditions in MSBuild.

@codecov-commenter
Copy link

Codecov Report

Merging #897 (3a97db9) into master (57ebcd8) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##           master     #897   +/-   ##
=======================================
  Coverage   95.17%   95.17%           
=======================================
  Files          42       42           
  Lines        1991     1991           
  Branches      336      336           
=======================================
  Hits         1895     1895           
  Misses         55       55           
  Partials       41       41           

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@Shane32
Copy link
Member Author

Shane32 commented Aug 17, 2022

Does this mean that other projects also have this problem?

Some of my other projects certainly did.

The same for AnalysisMode.

I really don't like the analyzer running for tests. It's very annoying, when it nit-picks at stuff that really doesn't make a difference, often causing test code that is inappropriate or harder to read than before. Here's some examples that annoy me for tests:

  1. async _ => true vs Task.FromResult(true)
  2. Methods containing one line of executable line of code vs => syntax.
  3. Misc naming conventions, which are often not appropriate for tests
  4. Unreferenced methods warnings (necessary for tests)
  5. Warnings that methods may be marked as static (necessary for tests)
  6. Warnings about unnecessary using statements (which are still a problem even without the analyzer)
  7. Warnings about one-line methods

I just looked at the 60 other warnings besides CA1707. There's only one warning that makes any sense for tests -- the int.Parse culture warnings. The rest do not apply. I definitely don't want the analyzer to run for tests. Sample code, maybe, but not tests.

Note that item 2 above is a particular problem for sample code; example below:

// -- this will not compile --
services.AddGraphQL(b => b
    .AddUserContextBuilder(httpContext =>
    {
        // you may add any data from the user context, like the value
        // of httpContext.User or Environment.IsDevelopment() or whatever you like
        return new MyUserContext(httpContext.User, Environment.IsDevelopment()));
    })
);

// -- .NET complains and wants this instead, which can be harder to read and does not leave room for comments --
services.AddGraphQL(b => b
    .AddUserContextBuilder(httpContext => new MyUserContext(httpContext.User, Environment.IsDevelopment()))
);

I suggest we merge this to fix the analyzer and readme as it was intended to be. If you want to create a subsequent PR with additional changes to the build process, I'll review it at that time.

@sungam3r
Copy link
Member

OK. Then I propose to disable all the rules that are not suitable for tests while turning the analysis on.

@Shane32 Shane32 merged commit 1cc7cc4 into master Aug 18, 2022
@Shane32 Shane32 deleted the fix_packing branch August 18, 2022 05:21
Kent-Chen-Conning added a commit to Conning/graphql-dotnet-server that referenced this pull request Oct 28, 2022
…4-upgrade-to-7.1

* commit 'af5ac03f9f5505d476850cee23c5aaa145110c94': (352 commits)
  Update response content type for `ExecutionResultActionResult` (graphql-dotnet#923)
  Bump Serilog.Sinks.Console from 4.0.1 to 4.1.0 (graphql-dotnet#924)
  Select return content type based on Accept header (graphql-dotnet#919)
  Allow the configuration of the response content type via options (graphql-dotnet#913)
  Change default response content type to match draft spec (graphql-dotnet#918)
  Add note regarding ASP.NET Core 2.1 support policy (graphql-dotnet#914)
  Bump Microsoft.NET.Test.Sdk from 17.3.0 to 17.3.1 (graphql-dotnet#920)
  Bump Shouldly from 4.0.3 to 4.1.0 (graphql-dotnet#912)
  Bump GraphQL to 7.0.2 (graphql-dotnet#911)
  Add file upload/download documentation to readme (graphql-dotnet#909)
  Fix packing readme and analysis recommendations (graphql-dotnet#897)
  Fix call to UseApolloTracing in Complex sample (graphql-dotnet#903)
  Add docs link
  Update migration document link (graphql-dotnet#895)
  Add federation tracing extension method (graphql-dotnet#894)
  Bump to GraphQL.NET 7.0.0 (graphql-dotnet#893)
  Feature/assembly-strongname (graphql-dotnet#892)
  Add JWT bearer authentication sample (graphql-dotnet#885)
  Bump Microsoft.AspNetCore.TestHost from 6.0.0 to 6.0.8 (graphql-dotnet#889)
  Bump Microsoft.NET.Test.Sdk from 17.2.0 to 17.3.0 (graphql-dotnet#890)
  ...

# Conflicts:
#	src/Transports.AspNetCore/GraphQLExtensions.cs
#	src/Transports.AspNetCore/GraphQLHttpMiddleware.cs
#	src/Transports.AspNetCore/Transports.AspNetCore.csproj
#	src/Transports.Subscriptions.Abstractions/ProtocolMessageListener.cs
#	src/Transports.Subscriptions.Abstractions/Subscription.cs
#	src/Transports.Subscriptions.Abstractions/SubscriptionServer.cs
#	src/Transports.Subscriptions.Abstractions/Transports.Subscriptions.Abstractions.csproj
#	src/Transports.Subscriptions.WebSockets/GraphQlWebSocketsMiddleware.cs
#	src/Transports.Subscriptions.WebSockets/Transports.Subscriptions.WebSockets.csproj
#	src/Transports.Subscriptions.WebSockets/WebSocketConnection.cs
#	src/Transports.Subscriptions.WebSockets/WebSocketReaderPipeline.cs
#	src/Ui.GraphiQL/Ui.GraphiQL.csproj
#	src/Ui.Playground/Ui.Playground.csproj
#	src/Ui.Voyager/Ui.Voyager.csproj
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants