Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add auto generated markers #3

Closed
wants to merge 1 commit into from
Closed
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
8 changes: 7 additions & 1 deletion Immutype/Components/Contracts.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
// ReSharper disable CheckNamespace
// ReSharper disable ClassNeverInstantiated.Global

// <auto-generated />

#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member

namespace Immutype
{
using System;

using System.CodeDom.Compiler;

[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Constructor, Inherited = false)]
public class TargetAttribute: Attribute { }
}
9 changes: 5 additions & 4 deletions Immutype/Core/ExtensionsFactory.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
// ReSharper disable ClassNeverInstantiated.Global
// ReSharper disable LoopCanBeConvertedToQuery
// ReSharper disable IdentifierTypo

namespace Immutype.Core;

#if ROSLYN38
using NamespaceType = NamespaceDeclarationSyntax;
#else
using NamespaceType = BaseNamespaceDeclarationSyntax;
using NamespaceType = BaseNamespaceDeclarationSyntax;
#endif

internal class ExtensionsFactory(IMethodsFactory methodsFactory) : IUnitFactory
Expand Down Expand Up @@ -50,7 +51,9 @@ public IEnumerable<Source> Create(GenerationContext<TypeDeclarationSyntax> conte
typeDeclarationSyntax.Identifier.Text
}));

yield return new Source(fileName, SourceText.From(code, Encoding.UTF8));
yield return new Source(fileName, SourceText.From(
"// <auto-generated />\n#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member\n\n" + code,
Encoding.UTF8));
}

private static CompilationUnitSyntax CreateRootNode(SyntaxNode targetNode, UsingDirectiveSyntax[] additionalUsings, params MemberDeclarationSyntax[] members)
Expand Down Expand Up @@ -84,11 +87,9 @@ private static ClassDeclarationSyntax TryAddAttribute(SemanticModel semanticMode
{
var excludeFromCodeCoverageType = semanticModel.Compilation.GetTypeByMetadataName(attributeClassName + "Attribute");
if (excludeFromCodeCoverageType != default)
{
classDeclarationSyntax = classDeclarationSyntax.WithNewLine()
.AddAttributeLists(SyntaxFactory.AttributeList().AddAttributes(SyntaxFactory.Attribute(SyntaxFactory.IdentifierName(attributeClassName))))
.WithNewLine();
}

return classDeclarationSyntax;
}
Expand Down
Loading