### Project Configuration with ThisAssembly.Git
Source: https://github.com/devlooped/thisassembly/blob/main/src/ThisAssembly.Git/readme.md
Example project setup demonstrating the integration of ThisAssembly.Git with Microsoft.SourceLink.GitHub and NuGetizer for seamless packaging and metadata population.
```xml
netstandard2.0
```
--------------------------------
### Include Embedded Resource
Source: https://github.com/devlooped/thisassembly/blob/main/src/ThisAssembly.Resources/readme.md
Add a markdown file as an embedded resource. This is a common setup for including documentation or other text-based assets.
```xml
```
--------------------------------
### Configure Text File Extensions
Source: https://github.com/devlooped/thisassembly/blob/main/src/ThisAssembly.Resources/readme.md
Customize which file extensions are treated as text files by default. This ensures that files like .txt, .cs, .sql, .json, and .md are read as strings.
```xml
.txt|.cs|.sql|.json|.md
```
--------------------------------
### Define Basic Constants
Source: https://github.com/devlooped/thisassembly/blob/main/src/ThisAssembly.Constants/readme.md
Define simple string constants using the `` MSBuild item. The `Value` attribute holds the constant's value, and the optional `Comment` attribute provides a description.
```xml
```
--------------------------------
### Generated ThisAssembly.Strings Class
Source: https://github.com/devlooped/thisassembly/blob/main/src/ThisAssembly.Strings/readme.md
This C# code demonstrates the structure of the generated ThisAssembly.Strings class, including nested classes for organizing string resources from Resx files. It shows how to access simple strings and strings with formatting parameters.
```csharp
partial class ThisAssembly
{
public static partial class Strings
{
public static partial class Infrastructure
{
///
/// For logging only!
/// => "Service {0} is required."
///
public static string MissingService(object arg0)
=> string.Format(CultureInfo.CurrentCulture,
Strings.GetResourceManager("ThisStore.Properties.Resources").GetString("MissingService"),
arg0);
}
public static partial class Shopping
{
///
/// => "We cannot ship {0} to {1}."
///
public static string NoShipping(object arg0, object arg1)
=> string.Format(CultureInfo.CurrentCulture,
Strings.GetResourceManager("ThisStore.Properties.Resources").GetString("NoShipping"),
arg0, arg1);
///
/// => "Product is out of stock at this time."
///
public static string OutOfStock
=> Strings.GetResourceManager("ThisStore.Properties.Resources").GetString("OutOfStock");
///
/// Product available on {date:yyyy-MM}.
///
public static string AvailableOn(object date)
=> string.Format(CultureInfo.CurrentCulture,
Strings.GetResourceManager("ThisAssemblyTests.Resources").GetString("WithNamedFormat").Replace("{date:yyyy-MM}", "{0}"),
((IFormattable)date).ToString("yyyy-MM", CultureInfo.CurrentCulture));
}
}
}
```
--------------------------------
### Define Project Constants
Source: https://github.com/devlooped/thisassembly/blob/main/readme.md
Define constants using MSBuild items. Supports arbitrary values, types, and comments. Values can be configured via environment variables or command line arguments.
```xml
```
```xml
10
```
--------------------------------
### Opting into ProjectProperty Generation
Source: https://github.com/devlooped/thisassembly/blob/main/src/ThisAssembly.Project/readme.md
Add MSBuild properties to the `ProjectProperty` item group to include them as constants in the generated `ThisAssembly.Project` class. You can also provide a custom comment.
```xml
Bar
```
--------------------------------
### Add Dynamic Embedded Resources
Source: https://github.com/devlooped/thisassembly/blob/main/src/ThisAssembly.Resources/readme.md
Define a target to add embedded resources dynamically before the PrepareEmbeddedResources build step. This allows including resources based on build configurations.
```xml
```
--------------------------------
### VSIX Manifest Placeholder Syntax
Source: https://github.com/devlooped/thisassembly/blob/main/src/ThisAssembly.Vsix/readme.md
Use placeholder syntax with the |ProjectName;TargetName| format in the VSIX manifest to leverage properties provided by ThisAssembly.Vsix. This avoids duplicating information across your project and manifest files.
```xml
|%CurrentProject%;VsixDisplayName|
|%CurrentProject%;VsixDescription|
...
```
--------------------------------
### Declare Assembly Metadata in Project File
Source: https://github.com/devlooped/thisassembly/blob/main/readme.md
Use the AssemblyMetadata MSBuild item to define arbitrary assembly attributes. These will be exposed as constants in the ThisAssembly.Metadata class.
```xml
```
--------------------------------
### Define Assembly Metadata in Project File
Source: https://github.com/devlooped/thisassembly/blob/main/src/ThisAssembly.Metadata/readme.md
Declare assembly metadata using MSBuild syntax in the project file for .NET 5.0+ projects. This enables the generation of corresponding constants in the ThisAssembly.Metadata class.
```xml
```
--------------------------------
### Generate Constants for Project Files
Source: https://github.com/devlooped/thisassembly/blob/main/src/ThisAssembly.Constants/readme.md
Generate constants for files within the project using the `` MSBuild item. This is particularly useful for test projects to reference project files.
```xml
```
--------------------------------
### Specify Resource Kind as Text
Source: https://github.com/devlooped/thisassembly/blob/main/src/ThisAssembly.Resources/readme.md
Explicitly mark an embedded resource as 'Text' using the Kind metadata. This overrides the default extension-based detection for specific files.
```xml
```
--------------------------------
### Opt-in Project Properties for ThisAssembly.Project
Source: https://github.com/devlooped/thisassembly/blob/main/readme.md
Declare project properties as ProjectProperty MSBuild items to expose them as constants in the ThisAssembly.Project class. You can also provide a custom comment.
```xml
Bar
```
--------------------------------
### Extending ThisAssembly with Custom Partial Class
Source: https://github.com/devlooped/thisassembly/blob/main/src/visibility.md
Define a custom partial class to modify the visibility of the generated class and add your own constants. Nested classes inherit visibility from the outer class.
```csharp
// makes the generated class public
public partial ThisAssembly
{
// Nested classes are always public since the outer class
// already limits their visibility
partial class Constants
{
// add some custom constants
public const string MyConstant = "This isn't configurable via MSBuild";
// generated code will remain as constants
}
}
```
--------------------------------
### Extending ThisAssembly with Custom Constants
Source: https://github.com/devlooped/thisassembly/blob/main/readme.md
Extends the generated ThisAssembly class to make it public and add custom constants. The generated code will remain as constants, while custom additions can be defined.
```csharp
// makes the generated class public
public partial ThisAssembly
{
// Nested classes are always public since the outer class
// already limits their visibility
partial class Constants
{
// add some custom constants
public const string MyConstant = "This isn\'t configurable via MSBuild";
// generated code will remain as constants
}
}
```
--------------------------------
### Define Typed Constants with MSBuild Properties
Source: https://github.com/devlooped/thisassembly/blob/main/src/ThisAssembly.Constants/readme.md
Define constants with specific C# types and values derived from MSBuild properties. This allows compile-time values to be configured via environment variables or command-line arguments.
```xml
10
```
--------------------------------
### Public ThisAssembly Class with Static Properties
Source: https://github.com/devlooped/thisassembly/blob/main/src/visibility.md
When `$(ThisAssemblyVisibility)` is set to public, the generated class becomes public and constants are converted to static readonly properties.
```csharp
public partial class ThisAssembly
{
public partial class Constants
{
public static string Hello => "World";
}
}
```
--------------------------------
### Default ThisAssembly Class Structure
Source: https://github.com/devlooped/thisassembly/blob/main/src/visibility.md
This is the default structure of the generated ThisAssembly class, with internal visibility and public constants.
```csharp
partial class ThisAssembly
{
public partial class Constants
{
public const string Hello = "World";
}
}
```
--------------------------------
### Consume Typed Constants in C#
Source: https://github.com/devlooped/thisassembly/blob/main/src/ThisAssembly.Constants/readme.md
Consume the generated constants in C# code. The generated constant's type matches the `Type` attribute specified in the MSBuild item, ensuring type safety.
```csharp
public HttpClient CreateHttpClient(string name, int? timeout = default)
{
HttpClient client = httpClientFactory.CreateClient(name);
client.Timeout = TimeSpan.FromSeconds(timeout ?? ThisAssembly.Constants.Http.TimeoutSeconds);
return client;
}
```
=== COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.