Skip to content

Commit

Permalink
Enable MarkdownSnippets.MsBuild
Browse files Browse the repository at this point in the history
  • Loading branch information
sungam3r committed Jan 23, 2024
1 parent d305f1f commit 44714d9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 20 deletions.
28 changes: 11 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,14 @@ Apply the `LogWithName` attribute:

<!-- snippet: LogWithName -->
<a id='snippet-logwithname'></a>
```csharp
using Destructurama.Attributed;
...
```cs
public class PersonalData
{
[LogWithName("FullName")]
public string? Name { get; set; }
}
```
<sup><a href='/test/Destructurama.Attributed.Tests/LogWithNameAttributedTests.cs#L37-L43' title='Snippet source file'>snippet source</a> | <a href='#snippet-logwithname' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Destructurama.Attributed.Tests/LogWithNameAttributedTests.cs#L36-L42' title='Snippet source file'>snippet source</a> | <a href='#snippet-logwithname' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

## 2. Ignoring a property
Expand All @@ -66,9 +64,7 @@ Apply the `NotLogged` attribute:

<!-- snippet: LoginCommand -->
<a id='snippet-logincommand'></a>
```csharp
using Destructurama.Attributed;
...
```cs
public class LoginCommand
{
public string? Username { get; set; }
Expand All @@ -77,18 +73,18 @@ public class LoginCommand
public string? Password { get; set; }
}
```
<sup><a href='/test/Destructurama.Attributed.Tests/Snippets.cs#L29-L37' title='Snippet source file'>snippet source</a> | <a href='#snippet-logincommand' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Destructurama.Attributed.Tests/Snippets.cs#L29-L37' title='Snippet source file'>snippet source</a> | <a href='#snippet-logincommand' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

When the object is passed using `{@...}` syntax the attributes will be consulted.

<!-- snippet: LogCommand -->
<a id='snippet-logcommand'></a>
```csharp
```cs
var command = new LoginCommand { Username = "logged", Password = "not logged" };
log.Information("Logging in {@Command}", command);
_log.Information("Logging in {@Command}", command);
```
<sup><a href='/test/Destructurama.Attributed.Tests/Snippets.cs#L44-L47' title='Snippet source file'>snippet source</a> | <a href='#snippet-logcommand' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Destructurama.Attributed.Tests/Snippets.cs#L44-L47' title='Snippet source file'>snippet source</a> | <a href='#snippet-logcommand' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

## 3. Ignoring a property if it has default value
Expand Down Expand Up @@ -164,9 +160,7 @@ Note that masking also works for properties of type `IEnumerable<string>` or der

<!-- snippet: CustomizedMaskedLogs -->
<a id='snippet-customizedmaskedlogs'></a>
```csharp
using Destructurama.Attributed;
...
```cs
public class CustomizedMaskedLogs
{
/// <summary>
Expand Down Expand Up @@ -284,7 +278,7 @@ public class CustomizedMaskedLogs
public string? ShowFirstAndLastThreeAndCustomMaskInTheMiddlePreservedLengthIgnored { get; set; }
}
```
<sup><a href='/test/Destructurama.Attributed.Tests/MaskedAttributeTests.cs#L10-L129' title='Snippet source file'>snippet source</a> | <a href='#snippet-customizedmaskedlogs' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Destructurama.Attributed.Tests/MaskedAttributeTests.cs#L9-L128' title='Snippet source file'>snippet source</a> | <a href='#snippet-customizedmaskedlogs' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

## 7. Masking a string property with regular expressions
Expand Down Expand Up @@ -319,7 +313,7 @@ __Available properties__:

<!-- snippet: WithRegex -->
<a id='snippet-withregex'></a>
```csharp
```cs
public class WithRegex
{
private const string REGEX_WITH_VERTICAL_BARS = @"([a-zA-Z0-9]+)\|([a-zA-Z0-9]+)\|([a-zA-Z0-9]+)";
Expand All @@ -337,5 +331,5 @@ public class WithRegex
public string? RegexReplaceSecond { get; set; }
}
```
<sup><a href='/test/Destructurama.Attributed.Tests/Snippets.cs#L6-L25' title='Snippet source file'>snippet source</a> | <a href='#snippet-withregex' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Destructurama.Attributed.Tests/Snippets.cs#L6-L25' title='Snippet source file'>snippet source</a> | <a href='#snippet-withregex' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
4 changes: 2 additions & 2 deletions mdsnippets.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
{
"$schema": "https://raw.githubusercontent.com/SimonCropp/MarkdownSnippets/master/schema.json",
"MaxWidth": 100,
"MaxWidth": 110,
"Convention": "InPlaceOverwrite"
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<!--<PackageReference Include="MarkdownSnippets.MsBuild" Version="24.5.1" PrivateAssets="all" />-->
<PackageReference Include="MarkdownSnippets.MsBuild" Version="24.5.1" PrivateAssets="all" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit 44714d9

Please sign in to comment.