Skip to content
Merged
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 6 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# If there are abnormal line endings in any file, run "git add --renormalize <file_name>",
# review the changes, and commit them to fix the line endings.
* text=auto

# Third-party library files should not have line endings normalized
**/wwwroot/lib/** -text
*.min.css -text
*.min.js -text
*.map -text
93 changes: 93 additions & 0 deletions .github/code-gen-instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# AppConfiguration-DotnetProvider Coding Guidelines

This document outlines coding guidelines for the Azure App Configuration .NET Provider repository. Follow these guidelines when generating or modifying code.

## General Guidelines

1. **Exception Handling**:
* When adding error handling, always catch specific exceptions and avoid catching the base `Exception` class in catch blocks.
* Throw specific exception types (e.g., `ArgumentNullException`, `FormatException`, custom exceptions) rather than generic `System.Exception`.
* Include the parameter name when throwing `ArgumentNullException` using `nameof()`.

2. **Variable Declaration**:
* Never use `var` to declare a variable if the assignment doesn't include the type or the type isn't immediately obvious.
* Use explicit type names for fields, properties, method parameters, and return types.
* Use `var` only when the type is obvious from the right-hand side (e.g., `var user = new User();`).

3. **Null Handling**:
* Validate arguments in public methods and constructors with explicit null checks.
* Use explicit `if (argument == null) throw new ArgumentNullException(nameof(argument));` checks at the beginning of methods/constructors.
* Avoid using the null-forgiving operator (`!`) unless absolutely necessary.

4. **Asynchronous Programming**:
* All async methods should accept a `CancellationToken` as the last parameter.
* Pass the `cancellationToken` down the call stack to all subsequent asynchronous operations.
* Use `Task<T>` or `Task` for asynchronous methods.

5. **LINQ and Collections**:
* Prefer simple, readable LINQ queries.
* Break down complex LINQ queries into separate statements with intermediate variables.
* Use collection interfaces (e.g., `IList<T>`, `IReadOnlyList<T>`) in parameter and return types.

6. **Resource Management**:
* Wrap `IDisposable` instances in `using` statements to ensure proper disposal.
* Implement `IDisposable` correctly if your class manages disposable objects.

7. **Dependency Injection**:
* Use constructor injection for dependencies.
* Store injected dependencies in `private readonly` fields.
* Validate injected dependencies for null in the constructor.

8. **Naming Conventions**:
* Use `PascalCase` for classes, interfaces, enums, methods, properties, and constants.
* Use `camelCase` for local variables and method parameters.
* Prefix private fields with an underscore (`_`).
* Define constants for error messages and other string literals.

9. **Comments**:
* Only add comments when it's not obvious what the code is doing. For example, if a variable name is already fairly descriptive, a comment isn't needed explaining its name.
* Add summary comments to public classes and members of those classes.

## AppConfiguration-Specific Guidelines

1. **Feature Flag Handling**:
* Validate feature flag data structure before processing.
* Handle different feature flag schemas (Microsoft vs .NET) appropriately.
* Use proper error handling when parsing feature flags with clear error messages.

2. **Configuration Key-Value Processing**:
* Follow adapter pattern for processing different configuration types.
* Properly handle key-value pairs with appropriate content type detection.
* Use `KeyValuePair<string, string>` for configuration values.

3. **Content Type Handling**:
* Validate content types before processing.
* Use appropriate content type constants.
* Check content type using extension methods like `IsFeatureFlag()`.

4. **JSON Parsing**:
* Use `Utf8JsonReader` for performance-critical JSON parsing.
* Validate JSON structure and provide clear error messages for malformed input.
* Handle JSON token types appropriately with proper error handling.

5. **Refresh Mechanisms**:
* Implement proper configuration refresh patterns.
* Use sentinel-based refresh mechanisms when appropriate.
* Handle refresh failures gracefully.

## Performance Considerations

1. **String Handling**:
* Use `StringBuilder` for concatenating multiple strings.
* Define string constants for recurring strings.
* Use string interpolation instead of string concatenation when appropriate.

2. **Collections**:
* Initialize collections with estimated capacity when possible.
* Use appropriate collection types for the use case (e.g., `List<T>`, `Dictionary<TKey, TValue>`).
* Avoid unnecessary collection allocations.

3. **Memory Management**:
* Use `Span<T>` and `ReadOnlySpan<T>` for high-performance scenarios.
* Minimize allocations in performance-critical paths.
* Be mindful of closure allocations in LINQ and lambdas.
3 changes: 3 additions & 0 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This is the Azure App Configuration .NET Provider codebase. The service abides by coding guidelines specified in the `github/code-gen-instructions.md` file.

When suggesting code changes, do not modify the files directly. Instead, provide a detailed explanation of the changes you would make and ask for confirmation before editing the files. You may create markdown files to demonstrate the changes you would like to make.
10 changes: 10 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ on:

permissions:
security-events: write
id-token: write

jobs:
build:
Expand All @@ -40,8 +41,17 @@ jobs:
- name: Dotnet Pack
run: pwsh pack.ps1

- name: Azure Login with OIDC
uses: azure/login@v1
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}

- name: Dotnet Test
run: pwsh test.ps1
env:
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}

- name: Publish Test Results
uses: actions/upload-artifact@v4
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
# Azure Functions localsettings file
local.settings.json

# Integration test secrets
appsettings.Secrets.json

# User-specific files
*.suo
*.user
Expand Down
10 changes: 10 additions & 0 deletions CodeQL.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
path_classifiers:
docs:
# Documentation
- "examples" # Exclude code samples from scan results
library:
# Library code
- ""
generated:
# Generated code
- ""
70 changes: 35 additions & 35 deletions examples/ConfigStoreDemo/Pages/_Layout.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -3,62 +3,62 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>@ViewData["Title"] - Azure App Configuration Demo</title>

<title>@ViewData["Title"] - Azure App Configuration Demo</title>
<environment include="Development">
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.css" />
</environment>
<link rel="stylesheet" href="~/lib/bootstrap/css/bootstrap.css" />
</environment>
<environment exclude="Development">
<link rel="stylesheet" href="https://ajax.aspnetcdn.com/ajax/bootstrap/3.3.7/css/bootstrap.min.css"
asp-fallback-href="~/lib/bootstrap/dist/css/bootstrap.min.css"
asp-fallback-test-class="sr-only" asp-fallback-test-property="position" asp-fallback-test-value="absolute" />
<link rel="stylesheet" href="https://ajax.aspnetcdn.com/ajax/bootstrap/5.2.3/css/bootstrap.min.css"
asp-fallback-href="~/lib/bootstrap/css/bootstrap.min.css"
asp-fallback-test-class="sr-only" asp-fallback-test-property="position" asp-fallback-test-value="absolute"
crossorigin="anonymous"
integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" />
</environment>
<link rel="stylesheet" href="~/css/site.css" />
<style>
@RenderSection("InlineStyles", required: false)
</style>
</head>
<body>
<nav class="navbar navbar-inverse navbar-fixed-top">
<nav class="navbar navbar-expand-lg navbar-dark bg-dark fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a asp-page="/Index" class="navbar-brand">@ViewData["AppName"]</a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li><a asp-page="/Index">Home</a></li>
<li><a asp-page="/About">About</a></li>
<li><a asp-page="/Contact">Contact</a></li>
<a asp-page="/Index" class="navbar-brand">@ViewData["AppName"]</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" asp-page="/Index">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" asp-page="/About">About</a>
</li>
<li class="nav-item">
<a class="nav-link" asp-page="/Contact">Contact</a>
</li>
</ul>
</div>
</div>
</nav>
<div class="container body-content">
@RenderBody()
</div>

</div>
<environment include="Development">
<script src="~/lib/jquery/dist/jquery.js"></script>
<script src="~/lib/bootstrap/dist/js/bootstrap.js"></script>
</environment>
<environment exclude="Development">
<script src="https://ajax.aspnetcdn.com/ajax/jquery/jquery-2.2.0.min.js"
asp-fallback-src="~/lib/jquery/dist/jquery.min.js"
<script src="~/lib/jquery/jquery.js"></script>
<script src="~/lib/bootstrap/js/bootstrap.bundle.js"></script>
</environment> <environment exclude="Development">
<script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.7.1.min.js"
asp-fallback-src="~/lib/jquery/jquery.min.js"
asp-fallback-test="window.jQuery"
crossorigin="anonymous"
integrity="sha384-K+ctZQ+LL8q6tP7I94W+qzQsfRV2a+AfHIi9k8z8l9ggpc8X+Ytst4yBo/hH+8Fk">
integrity="sha384-1H217gwSVyLSIfaLxHbE7dRb3v4mYCKbpQvzx0cegeju1MVsGrX5xXxAvs/HgeFs">
</script>
<script src="https://ajax.aspnetcdn.com/ajax/bootstrap/3.3.7/bootstrap.min.js"
asp-fallback-src="~/lib/bootstrap/dist/js/bootstrap.min.js"
asp-fallback-test="window.jQuery && window.jQuery.fn && window.jQuery.fn.modal"
<script src="https://ajax.aspnetcdn.com/ajax/bootstrap/5.2.3/bootstrap.bundle.min.js"
asp-fallback-src="~/lib/bootstrap/js/bootstrap.bundle.min.js"
asp-fallback-test="window.bootstrap"
crossorigin="anonymous"
integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa">
integrity="sha384-kenU1KFdBIe4zVF0s0G1M5b4hcpxyD9F7jL+jjXkk+Q2h455rYXK/7HAuoJl+0I4">
</script>
</environment>
<script src="~/js/site.js" asp-append-version="true"></script>
Expand Down
12 changes: 6 additions & 6 deletions examples/ConfigStoreDemo/Pages/_ValidationScriptsPartial.cshtml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<environment include="Development">
<script src="~/lib/jquery-validation/dist/jquery.validate.js"></script>
<script src="~/lib/jquery-validation/jquery.validate.js"></script>
<script src="~/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.js"></script>
</environment>
<environment exclude="Development">
<script src="https://ajax.aspnetcdn.com/ajax/jquery.validate/1.14.0/jquery.validate.min.js"
asp-fallback-src="~/lib/jquery-validation/dist/jquery.validate.min.js"
<script src="https://ajax.aspnetcdn.com/ajax/jquery.validate/1.19.2/jquery.validate.min.js"
asp-fallback-src="~/lib/jquery-validation/jquery.validate.min.js"
asp-fallback-test="window.jQuery && window.jQuery.validator"
crossorigin="anonymous"
integrity="sha384-Fnqn3nxp3506LP/7Y3j/25BlWeA3PXTyT1l78LjECcPaKCV12TsZP7yyMxOe/G/k">
integrity="sha384-MZR6XL4hQZmTk8/fNfJ2v1HF4JQJvHJdgwfEjpZFKG6RQUbO4q2hKTlGt7vHBNW">
</script>
<script src="https://ajax.aspnetcdn.com/ajax/jquery.validation.unobtrusive/3.2.6/jquery.validate.unobtrusive.min.js"
<script src="https://ajax.aspnetcdn.com/ajax/jquery.validation.unobtrusive/3.2.10/jquery.validate.unobtrusive.min.js"
asp-fallback-src="~/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.min.js"
asp-fallback-test="window.jQuery && window.jQuery.validator && window.jQuery.validator.unobtrusive"
crossorigin="anonymous"
integrity="sha384-JrXK+k53HACyavUKOsL+NkmSesD2P+73eDMrbTtTk0h4RmOF8hF8apPlkp26JlyH">
integrity="sha384-ifv0TYDWxBHzvAk2Z0n8R434FL1Rlv/Av18DXE43N/1rvHyOG4izKst0f2iSLdds">
</script>
</environment>
26 changes: 26 additions & 0 deletions examples/ConfigStoreDemo/libman.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"version": "1.0",
"defaultProvider": "unpkg",
"libraries": [
{
"provider": "unpkg",
"library": "jquery@3.7.1",
"destination": "wwwroot/lib/jquery/"
},
{
"provider": "unpkg",
"library": "jquery-validation@1.19.2",
"destination": "wwwroot/lib/jquery-validation/"
},
{
"provider": "unpkg",
"library": "jquery-validation-unobtrusive@3.2.10",
"destination": "wwwroot/lib/jquery-validation-unobtrusive/"
},
{
"provider": "unpkg",
"library": "bootstrap@5.2.3",
"destination": "wwwroot/lib/bootstrap/"
}
]
}
6 changes: 3 additions & 3 deletions examples/ConfigStoreDemo/wwwroot/css/site.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
body {
padding-top: 50px;
padding-top: 56px;
padding-bottom: 20px;
}

Expand Down Expand Up @@ -40,7 +40,7 @@ body {
}

.center {
margin-top: 50%;
margin-top: 40vh;
font-size: 50px;
text-align: center;
}
}
45 changes: 0 additions & 45 deletions examples/ConfigStoreDemo/wwwroot/lib/bootstrap/.bower.json

This file was deleted.

21 changes: 0 additions & 21 deletions examples/ConfigStoreDemo/wwwroot/lib/bootstrap/LICENSE

This file was deleted.

Loading