Skip to content

Commit a69a6d7

Browse files
committed
Add attributes to beginning of file
1 parent 95dae83 commit a69a6d7

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/packageSourceGenerator/PackageSourceGeneratorTask/AddAttributes.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,9 @@ private bool AddAttributesToFile(string CSharpPath) {
4646
.ToArray();
4747

4848
string attributesToAppend = string.Join(Environment.NewLine, attributesNotInFile);
49-
string replacement = "]" + Environment.NewLine + attributesToAppend + Environment.NewLine + "namespace";
49+
string replacement = Environment.NewLine + attributesToAppend + "\n[assembly:";
5050

51-
Log.LogMessage(MessageImportance.Low, $"Adding newline {replacement} to {CSharpPath}");
52-
53-
string modifiedContent = GetEndOfAttributesRegex().Replace(fileContent, replacement);
51+
string modifiedContent = GetBeginningOfAttributesRegex().Replace(fileContent, replacement, 1);
5452

5553
File.WriteAllText(CSharpPath, modifiedContent);
5654

@@ -61,7 +59,7 @@ private bool AddAttributesToFile(string CSharpPath) {
6159
return true;
6260
}
6361

64-
[GeneratedRegex(@"\]\nnamespace")]
65-
private static partial Regex GetEndOfAttributesRegex();
62+
[GeneratedRegex(@"\n\[assembly:")]
63+
private static partial Regex GetBeginningOfAttributesRegex();
6664
}
6765
}

0 commit comments

Comments
 (0)