Skip to content

Commit 6809fdc

Browse files
Merge pull request #704 from Azure/zhiyuanliang/merge-main-to-preview
Merge main to preview
2 parents a992b59 + e409926 commit 6809fdc

File tree

339 files changed

+90309
-14938
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

339 files changed

+90309
-14938
lines changed

.gitattributes

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
# If there are abnormal line endings in any file, run "git add --renormalize <file_name>",
22
# review the changes, and commit them to fix the line endings.
33
* text=auto
4+
5+
# Third-party library files should not have line endings normalized
6+
**/wwwroot/lib/** -text
7+
*.min.css -text
8+
*.min.js -text
9+
*.map -text

.github/code-gen-instructions.md

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# AppConfiguration-DotnetProvider Coding Guidelines
2+
3+
This document outlines coding guidelines for the Azure App Configuration .NET Provider repository. Follow these guidelines when generating or modifying code.
4+
5+
## General Guidelines
6+
7+
1. **Exception Handling**:
8+
* When adding error handling, always catch specific exceptions and avoid catching the base `Exception` class in catch blocks.
9+
* Throw specific exception types (e.g., `ArgumentNullException`, `FormatException`, custom exceptions) rather than generic `System.Exception`.
10+
* Include the parameter name when throwing `ArgumentNullException` using `nameof()`.
11+
12+
2. **Variable Declaration**:
13+
* Never use `var` to declare a variable if the assignment doesn't include the type or the type isn't immediately obvious.
14+
* Use explicit type names for fields, properties, method parameters, and return types.
15+
* Use `var` only when the type is obvious from the right-hand side (e.g., `var user = new User();`).
16+
17+
3. **Null Handling**:
18+
* Validate arguments in public methods and constructors with explicit null checks.
19+
* Use explicit `if (argument == null) throw new ArgumentNullException(nameof(argument));` checks at the beginning of methods/constructors.
20+
* Avoid using the null-forgiving operator (`!`) unless absolutely necessary.
21+
22+
4. **Asynchronous Programming**:
23+
* All async methods should accept a `CancellationToken` as the last parameter.
24+
* Pass the `cancellationToken` down the call stack to all subsequent asynchronous operations.
25+
* Use `Task<T>` or `Task` for asynchronous methods.
26+
27+
5. **LINQ and Collections**:
28+
* Prefer simple, readable LINQ queries.
29+
* Break down complex LINQ queries into separate statements with intermediate variables.
30+
* Use collection interfaces (e.g., `IList<T>`, `IReadOnlyList<T>`) in parameter and return types.
31+
32+
6. **Resource Management**:
33+
* Wrap `IDisposable` instances in `using` statements to ensure proper disposal.
34+
* Implement `IDisposable` correctly if your class manages disposable objects.
35+
36+
7. **Dependency Injection**:
37+
* Use constructor injection for dependencies.
38+
* Store injected dependencies in `private readonly` fields.
39+
* Validate injected dependencies for null in the constructor.
40+
41+
8. **Naming Conventions**:
42+
* Use `PascalCase` for classes, interfaces, enums, methods, properties, and constants.
43+
* Use `camelCase` for local variables and method parameters.
44+
* Prefix private fields with an underscore (`_`).
45+
* Define constants for error messages and other string literals.
46+
47+
9. **Comments**:
48+
* 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.
49+
* Add summary comments to public classes and members of those classes.
50+
51+
## AppConfiguration-Specific Guidelines
52+
53+
1. **Feature Flag Handling**:
54+
* Validate feature flag data structure before processing.
55+
* Handle different feature flag schemas (Microsoft vs .NET) appropriately.
56+
* Use proper error handling when parsing feature flags with clear error messages.
57+
58+
2. **Configuration Key-Value Processing**:
59+
* Follow adapter pattern for processing different configuration types.
60+
* Properly handle key-value pairs with appropriate content type detection.
61+
* Use `KeyValuePair<string, string>` for configuration values.
62+
63+
3. **Content Type Handling**:
64+
* Validate content types before processing.
65+
* Use appropriate content type constants.
66+
* Check content type using extension methods like `IsFeatureFlag()`.
67+
68+
4. **JSON Parsing**:
69+
* Use `Utf8JsonReader` for performance-critical JSON parsing.
70+
* Validate JSON structure and provide clear error messages for malformed input.
71+
* Handle JSON token types appropriately with proper error handling.
72+
73+
5. **Refresh Mechanisms**:
74+
* Implement proper configuration refresh patterns.
75+
* Use sentinel-based refresh mechanisms when appropriate.
76+
* Handle refresh failures gracefully.
77+
78+
## Performance Considerations
79+
80+
1. **String Handling**:
81+
* Use `StringBuilder` for concatenating multiple strings.
82+
* Define string constants for recurring strings.
83+
* Use string interpolation instead of string concatenation when appropriate.
84+
85+
2. **Collections**:
86+
* Initialize collections with estimated capacity when possible.
87+
* Use appropriate collection types for the use case (e.g., `List<T>`, `Dictionary<TKey, TValue>`).
88+
* Avoid unnecessary collection allocations.
89+
90+
3. **Memory Management**:
91+
* Use `Span<T>` and `ReadOnlySpan<T>` for high-performance scenarios.
92+
* Minimize allocations in performance-critical paths.
93+
* Be mindful of closure allocations in LINQ and lambdas.

.github/copilot-instructions.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
This is the Azure App Configuration .NET Provider codebase. The service abides by coding guidelines specified in the `github/code-gen-instructions.md` file.
2+
3+
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.

CodeQL.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
path_classifiers:
2+
docs:
3+
# Documentation
4+
- "examples" # Exclude code samples from scan results
5+
library:
6+
# Library code
7+
- ""
8+
generated:
9+
# Generated code
10+
- ""

build/install-dotnet.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# Installs .NET 6 and .NET 8 for CI/CD environment
1+
# Installs .NET 8 and .NET 9 for CI/CD environment
22
# see: https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-install-script#examples
33

44
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12;
55

6-
&([scriptblock]::Create((Invoke-WebRequest -UseBasicParsing 'https://dot.net/v1/dotnet-install.ps1'))) -Channel 6.0
7-
86
&([scriptblock]::Create((Invoke-WebRequest -UseBasicParsing 'https://dot.net/v1/dotnet-install.ps1'))) -Channel 8.0
7+
8+
&([scriptblock]::Create((Invoke-WebRequest -UseBasicParsing 'https://dot.net/v1/dotnet-install.ps1'))) -Channel 9.0

examples/ConfigStoreDemo/Pages/_Layout.cshtml

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3,62 +3,62 @@
33
<head>
44
<meta charset="utf-8" />
55
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6-
<title>@ViewData["Title"] - Azure App Configuration Demo</title>
7-
6+
<title>@ViewData["Title"] - Azure App Configuration Demo</title>
87
<environment include="Development">
9-
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.css" />
10-
</environment>
8+
<link rel="stylesheet" href="~/lib/bootstrap/css/bootstrap.css" />
9+
</environment>
1110
<environment exclude="Development">
12-
<link rel="stylesheet" href="https://ajax.aspnetcdn.com/ajax/bootstrap/3.3.7/css/bootstrap.min.css"
13-
asp-fallback-href="~/lib/bootstrap/dist/css/bootstrap.min.css"
14-
asp-fallback-test-class="sr-only" asp-fallback-test-property="position" asp-fallback-test-value="absolute" />
11+
<link rel="stylesheet" href="https://ajax.aspnetcdn.com/ajax/bootstrap/5.2.3/css/bootstrap.min.css"
12+
asp-fallback-href="~/lib/bootstrap/css/bootstrap.min.css"
13+
asp-fallback-test-class="sr-only" asp-fallback-test-property="position" asp-fallback-test-value="absolute"
14+
crossorigin="anonymous"
15+
integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" />
1516
</environment>
1617
<link rel="stylesheet" href="~/css/site.css" />
1718
<style>
1819
@RenderSection("InlineStyles", required: false)
1920
</style>
2021
</head>
2122
<body>
22-
<nav class="navbar navbar-inverse navbar-fixed-top">
23+
<nav class="navbar navbar-expand-lg navbar-dark bg-dark fixed-top">
2324
<div class="container">
24-
<div class="navbar-header">
25-
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
26-
<span class="sr-only">Toggle navigation</span>
27-
<span class="icon-bar"></span>
28-
<span class="icon-bar"></span>
29-
<span class="icon-bar"></span>
30-
</button>
31-
<a asp-page="/Index" class="navbar-brand">@ViewData["AppName"]</a>
32-
</div>
33-
<div class="navbar-collapse collapse">
34-
<ul class="nav navbar-nav">
35-
<li><a asp-page="/Index">Home</a></li>
36-
<li><a asp-page="/About">About</a></li>
37-
<li><a asp-page="/Contact">Contact</a></li>
25+
<a asp-page="/Index" class="navbar-brand">@ViewData["AppName"]</a>
26+
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
27+
<span class="navbar-toggler-icon"></span>
28+
</button>
29+
<div class="collapse navbar-collapse" id="navbarNav">
30+
<ul class="navbar-nav">
31+
<li class="nav-item">
32+
<a class="nav-link" asp-page="/Index">Home</a>
33+
</li>
34+
<li class="nav-item">
35+
<a class="nav-link" asp-page="/About">About</a>
36+
</li>
37+
<li class="nav-item">
38+
<a class="nav-link" asp-page="/Contact">Contact</a>
39+
</li>
3840
</ul>
3941
</div>
4042
</div>
4143
</nav>
4244
<div class="container body-content">
4345
@RenderBody()
44-
</div>
45-
46+
</div>
4647
<environment include="Development">
47-
<script src="~/lib/jquery/dist/jquery.js"></script>
48-
<script src="~/lib/bootstrap/dist/js/bootstrap.js"></script>
49-
</environment>
50-
<environment exclude="Development">
51-
<script src="https://ajax.aspnetcdn.com/ajax/jquery/jquery-2.2.0.min.js"
52-
asp-fallback-src="~/lib/jquery/dist/jquery.min.js"
48+
<script src="~/lib/jquery/jquery.js"></script>
49+
<script src="~/lib/bootstrap/js/bootstrap.bundle.js"></script>
50+
</environment> <environment exclude="Development">
51+
<script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.7.1.min.js"
52+
asp-fallback-src="~/lib/jquery/jquery.min.js"
5353
asp-fallback-test="window.jQuery"
5454
crossorigin="anonymous"
55-
integrity="sha384-K+ctZQ+LL8q6tP7I94W+qzQsfRV2a+AfHIi9k8z8l9ggpc8X+Ytst4yBo/hH+8Fk">
55+
integrity="sha384-1H217gwSVyLSIfaLxHbE7dRb3v4mYCKbpQvzx0cegeju1MVsGrX5xXxAvs/HgeFs">
5656
</script>
57-
<script src="https://ajax.aspnetcdn.com/ajax/bootstrap/3.3.7/bootstrap.min.js"
58-
asp-fallback-src="~/lib/bootstrap/dist/js/bootstrap.min.js"
59-
asp-fallback-test="window.jQuery && window.jQuery.fn && window.jQuery.fn.modal"
57+
<script src="https://ajax.aspnetcdn.com/ajax/bootstrap/5.2.3/bootstrap.bundle.min.js"
58+
asp-fallback-src="~/lib/bootstrap/js/bootstrap.bundle.min.js"
59+
asp-fallback-test="window.bootstrap"
6060
crossorigin="anonymous"
61-
integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa">
61+
integrity="sha384-kenU1KFdBIe4zVF0s0G1M5b4hcpxyD9F7jL+jjXkk+Q2h455rYXK/7HAuoJl+0I4">
6262
</script>
6363
</environment>
6464
<script src="~/js/site.js" asp-append-version="true"></script>
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
<environment include="Development">
2-
<script src="~/lib/jquery-validation/dist/jquery.validate.js"></script>
2+
<script src="~/lib/jquery-validation/jquery.validate.js"></script>
33
<script src="~/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.js"></script>
44
</environment>
55
<environment exclude="Development">
6-
<script src="https://ajax.aspnetcdn.com/ajax/jquery.validate/1.14.0/jquery.validate.min.js"
7-
asp-fallback-src="~/lib/jquery-validation/dist/jquery.validate.min.js"
6+
<script src="https://ajax.aspnetcdn.com/ajax/jquery.validate/1.19.2/jquery.validate.min.js"
7+
asp-fallback-src="~/lib/jquery-validation/jquery.validate.min.js"
88
asp-fallback-test="window.jQuery && window.jQuery.validator"
99
crossorigin="anonymous"
10-
integrity="sha384-Fnqn3nxp3506LP/7Y3j/25BlWeA3PXTyT1l78LjECcPaKCV12TsZP7yyMxOe/G/k">
10+
integrity="sha384-MZR6XL4hQZmTk8/fNfJ2v1HF4JQJvHJdgwfEjpZFKG6RQUbO4q2hKTlGt7vHBNW">
1111
</script>
12-
<script src="https://ajax.aspnetcdn.com/ajax/jquery.validation.unobtrusive/3.2.6/jquery.validate.unobtrusive.min.js"
12+
<script src="https://ajax.aspnetcdn.com/ajax/jquery.validation.unobtrusive/3.2.10/jquery.validate.unobtrusive.min.js"
1313
asp-fallback-src="~/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.min.js"
1414
asp-fallback-test="window.jQuery && window.jQuery.validator && window.jQuery.validator.unobtrusive"
1515
crossorigin="anonymous"
16-
integrity="sha384-JrXK+k53HACyavUKOsL+NkmSesD2P+73eDMrbTtTk0h4RmOF8hF8apPlkp26JlyH">
16+
integrity="sha384-ifv0TYDWxBHzvAk2Z0n8R434FL1Rlv/Av18DXE43N/1rvHyOG4izKst0f2iSLdds">
1717
</script>
1818
</environment>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"version": "1.0",
3+
"defaultProvider": "unpkg",
4+
"libraries": [
5+
{
6+
"provider": "unpkg",
7+
"library": "[email protected]",
8+
"destination": "wwwroot/lib/jquery/"
9+
},
10+
{
11+
"provider": "unpkg",
12+
"library": "[email protected]",
13+
"destination": "wwwroot/lib/jquery-validation/"
14+
},
15+
{
16+
"provider": "unpkg",
17+
"library": "[email protected]",
18+
"destination": "wwwroot/lib/jquery-validation-unobtrusive/"
19+
},
20+
{
21+
"provider": "unpkg",
22+
"library": "[email protected]",
23+
"destination": "wwwroot/lib/bootstrap/"
24+
}
25+
]
26+
}

examples/ConfigStoreDemo/wwwroot/css/site.css

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
body {
2-
padding-top: 50px;
2+
padding-top: 56px;
33
padding-bottom: 20px;
44
}
55

@@ -40,7 +40,7 @@ body {
4040
}
4141

4242
.center {
43-
margin-top: 50%;
43+
margin-top: 40vh;
4444
font-size: 50px;
4545
text-align: center;
46-
}
46+
}

examples/ConfigStoreDemo/wwwroot/lib/bootstrap/.bower.json

Lines changed: 0 additions & 45 deletions
This file was deleted.

0 commit comments

Comments
 (0)