You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to reduce the number of warnings in a project I'm working on. Most of them are CS1591 "Missing XML comment [...]". I've searched the issues and found the following PR #8940 where the issue should have been solved.
Now here is the thing, I've got static classes which do wrap DTOs used by my grains. The result is that the source generator creates two different namespaces:
and the #pragma warning disable CS1591 only wraps the first namespace. The result is that I get warnings for all remaining classes inside different namespaces for the given output file OrleansPlaygroundApp.orleans.g.cs.
While writing the issue I also recognize that this happens when there are multiple classes in different namespaces - not nested - that do use [GenerateSerializer], so my issue isn't only related to the static class with its nested DTOs but occurs as soon as you have different namespaces.
If I remove the DTOs from the static class and make them standalone the directive gets properly added to the end of the file #pragma warning restore CS1591. But currently it gets added right above namespace OrleansCodeGen.OrleansPlaygroundApp.AccountRelationshipContracts
Expected behavior:
Directive #pragma warning restore CS1591 gets added to the very end of the generated source code or maybe leave it out completely as far as I can see restoring is not necessary. The latter would be the same solution that seems to be implemented by the logger source generator from the Microsoft.Extensions.Telemetry.Abstractions package.
Create two DTO classes in two different namespaces and add the Attribute [GenerateSerializer] to them (or use the examples provided below)
Hit compile
Inspect the generated source file
Static AccountContracts
usingOrleans;namespaceOrleansPlaygroundApp;/* Does not work as it ends up in a different namespace than AccountRelationshipContracts Comment the following code to see the error. *//// <summary>/// Contains the contracts for the accounts/// </summary>publicstaticclassAccountContracts{/// <summary>/// Initialize a new account./// </summary>[GenerateSerializer][Immutable]publicsealedclassStoreAccountDataTransferObject{/// <summary>/// The account that should be stored./// </summary>[Id(0)]publicstring?AccountId{get;set;}}/// <summary>/// Marks an account as deleted./// </summary>[GenerateSerializer][Immutable]publicsealedclassDeactivateAccountDataTransferObject{/// <summary>/// The account that should be marked as deleted./// </summary>[Id(0)]publicstring?AccountId{get;set;}}}/* Does work as every class is going into the same namespace. Uncomment the following code to see the error. *////// <summary>///// Initialize a new account.///// </summary>//[GenerateSerializer]//[Immutable]//public sealed class StoreAccountDataTransferObject//{// /// <summary>// /// The account that should be stored.// /// </summary>// [Id(0)]// public string? AccountId { get; set; }//}///// <summary>///// Marks an account as deleted.///// </summary>//[GenerateSerializer]//[Immutable]//public sealed class DeactivateAccountDataTransferObject//{// /// <summary>// /// The account that should be marked as deleted.// /// </summary>// [Id(0)]// public string? AccountId { get; set; }//}
Static AccountRelationshipContracts
usingOrleans;namespaceOrleansPlaygroundApp;/* Does not work as it ends up in a different namespace than AccountRelationshipContracts Comment the following code to see the error. *//// <summary>/// Contains the contracts for the account relationship./// </summary>publicstaticclassAccountRelationshipContracts{/// <summary>/// Creates a relationship between two accounts./// </summary>[GenerateSerializer][Immutable]publicsealedclassEstablishAccountRelationshipDataTransferObject{/// <summary>/// The account that is the head of the relationship./// </summary>[Id(0)]publicstring?HeadAccountId{get;set;}/// <summary>/// The account that is the tail of the relationship./// </summary>[Id(1)]publicstring?TailAccountId{get;set;}}}/* Does work as every class is going into the same namespace. Uncomment the following code to see the error. *////// <summary>///// Creates a relationship between two accounts.///// </summary>//[GenerateSerializer]//[Immutable]//public sealed class EstablishAccountRelationshipDataTransferObject//{// /// <summary>// /// The account that is the head of the relationship.// /// </summary>// [Id(0)]// public string? HeadAccountId { get; set; }// /// <summary>// /// The account that is the tail of the relationship.// /// </summary>// [Id(1)]// public string? TailAccountId { get; set; }//}
The text was updated successfully, but these errors were encountered:
Cotspheer
changed the title
#pragma warning disable CS1591 only works for the first namespace when classes are nested
#pragma warning disable CS1591 only works for the first namespace
Mar 18, 2025
Change line 383 to the following namespaces[namespaces.Count - 1] = namespaces[namespaces.Count - 1]
With the latter solution the restore would be appended to the end of the very last namespace. But it would have the same effect as removing the whole block.
Description
I'm trying to reduce the number of warnings in a project I'm working on. Most of them are CS1591 "Missing XML comment [...]". I've searched the issues and found the following PR #8940 where the issue should have been solved.
Now here is the thing, I've got static classes which do wrap DTOs used by my grains. The result is that the source generator creates two different namespaces:
OrleansCodeGen.OrleansPlaygroundApp.AccountContracts
OrleansCodeGen.OrleansPlaygroundApp.AccountRelationshipContracts
and the
#pragma warning disable CS1591
only wraps the first namespace. The result is that I get warnings for all remaining classes inside different namespaces for the given output fileOrleansPlaygroundApp.orleans.g.cs
.While writing the issue I also recognize that this happens when there are multiple classes in different namespaces - not nested - that do use
[GenerateSerializer]
, so my issue isn't only related to the static class with its nested DTOs but occurs as soon as you have different namespaces.If I remove the DTOs from the static class and make them standalone the directive gets properly added to the end of the file
#pragma warning restore CS1591
. But currently it gets added right abovenamespace OrleansCodeGen.OrleansPlaygroundApp.AccountRelationshipContracts
Expected behavior:
Directive
#pragma warning restore CS1591
gets added to the very end of the generated source code or maybe leave it out completely as far as I can see restoring is not necessary. The latter would be the same solution that seems to be implemented by the logger source generator from theMicrosoft.Extensions.Telemetry.Abstractions
package.Versions
How to reproduce:
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
<CompilerGeneratedFilesOutputPath>Generated</CompilerGeneratedFilesOutputPath>
Static AccountContracts
Static AccountRelationshipContracts
Generated Output
Logging.g.cs from Microsoft.Extensions.Telemetry.Abstractions
The text was updated successfully, but these errors were encountered: