Skip to content

Commit d2fa60c

Browse files
author
Rick Neeft
committed
New Blog Post prompt for a prompt
1 parent 4e8cc0a commit d2fa60c

3 files changed

Lines changed: 39 additions & 2 deletions

File tree

_config.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ social:
3838
email: rick.neeft@outlook.com # change to your email address
3939
links:
4040
# The first element serves as the copyright owner's link
41-
- https://twitter.com/rneeft # change to your twitter homepage
4241
- https://github.com/rneeft # change to your github homepage
4342
# Uncomment below to add more social links
4443
# - https://www.facebook.com/username

_posts/2025-11-02-grub-edits.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: How to Show the GRUB Menu and Boot Information on Startup in Ubuntu
3-
date: 2025-02-11 16:11:00 +0100
3+
date: 2025-11-02 16:11:00 +0100
44
categories: [Grub, Ubuntu, Linux]
55
tags: [grub, ubuntu, linux, boot] # TAG names should always be lowercase
66
---
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
title: How to generate prompts for Copilot by Copilot
3+
date: 2025-11-07 14:55:00 +0100
4+
categories: [AI, Copilot]
5+
tags: [copilot, prompts, ai, logging, sourcegenerator] # TAG names should always be lowercase
6+
---
7+
8+
When I'm coding and Copilot is trying to help me, creating a good prompt can sometimes be very challenging. But did you know you can let Copilot create a prompt for you?
9+
10+
### Context
11+
I'm replacing all ILogger messages by moving them into a separate `partial class` and making use of the source generator `ILoggerMessage` to prevent boxing when the LogLevel is not logged anyway. Nick Chapsas has a whole [Youtube Video](https://youtu.be/a26zu-pyEyg?t=676) explaining this topic in detail, but the 'why' is out-of-scope for this blog.
12+
13+
This refactoring work is repetitive and tedious, so how can Copilot help me with this? I had no clue what kind of prompt I should give it. So how about asking Copilot for help?
14+
15+
### Getting Copilot to Create a Prompt
16+
17+
I created two files: the original version and a second one with the changes applied. Then I simply asked Copilot for a prompt:
18+
19+
```
20+
I have these two C# files showing a before and after refactoring where I moved all ILogger calls into a separate static partial class using the LoggerMessage source generator pattern. Please analyze the changes and create a clear, copy-and-paste prompt that I can use with Copilot to apply this same refactoring pattern to other classes in the future. The prompt should specify the ILoggerMessage approach and include concrete examples.
21+
```
22+
23+
Copilot will now return a prompt that I can use later in other classes.
24+
25+
```
26+
Refactor this class to move all logging statements into a separate static partial class using the LoggerMessage attribute pattern.
27+
Instructions:
28+
• Create a static partial class named [ClassName]Log (replace [ClassName] with the main class name).
29+
• Add the newly created class into the same file as [ClassName]
30+
• For each log statement, define a corresponding static partial method in the log class, decorated with [LoggerMessage] and the appropriate log level, message, and parameters.
31+
• Replace direct calls to _logger.LogInformation, _logger.LogError, etc., in the main class with calls to the new static partial methods.
32+
• Ensure the main class only calls these new logging methods, passing the logger instance as this ILogger<[ClassName]> logger.
33+
• Do not change the logic or structure of the main class, except for replacing the logging calls.
34+
Example:
35+
// Before: _logger.LogInformation("Starting scheduled {HttpMethod} call to {RequestPath}", method, url);
36+
// After: _logger.StartingScheduledHttpCall(method, url);
37+
// In the static partial log class: [LoggerMessage(Level = LogLevel.Information, Message = "Starting scheduled {HttpMethod} call to {RequestPath}")] public static partial void StartingScheduledHttpCall(this ILogger<MitzHttpJob> logger, HttpMethod httpMethod, string? requestPath);
38+
```

0 commit comments

Comments
 (0)