-
Notifications
You must be signed in to change notification settings - Fork 717
Single-quote OData strings within parentheses syntax #1153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
commonsensesoftware
wants to merge
1
commit into
main
Choose a base branch
from
dev/ccs/issue-1152
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
...p.Versioning.OData.ApiExplorer.Tests/Simulators/Configuration/RecordModelConfiguration.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| // Copyright (c) .NET Foundation and contributors. All rights reserved. | ||
|
|
||
| namespace Asp.Versioning.Simulators.Configuration; | ||
|
|
||
| using Asp.Versioning.OData; | ||
| using Asp.Versioning.Simulators.Models; | ||
| using Microsoft.OData.ModelBuilder; | ||
|
|
||
| /// <summary> | ||
| /// Represents the model configuration for records. | ||
| /// </summary> | ||
| public class RecordModelConfiguration : IModelConfiguration | ||
| { | ||
| /// <inheritdoc /> | ||
| public void Apply( ODataModelBuilder builder, ApiVersion apiVersion, string routePrefix ) | ||
| { | ||
| ArgumentNullException.ThrowIfNull( builder ); | ||
|
|
||
| if ( apiVersion == ApiVersions.V1 ) | ||
| { | ||
| builder.EntitySet<Record>( "Records" ).EntityType.HasKey( r => new { r.Id, r.Source } ); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
src/AspNetCore/OData/test/Asp.Versioning.OData.ApiExplorer.Tests/Simulators/Models/Record.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| // Copyright (c) .NET Foundation and contributors. All rights reserved. | ||
|
|
||
| namespace Asp.Versioning.Simulators.Models; | ||
|
|
||
| public class Record | ||
| { | ||
| public string Id { get; set; } | ||
|
|
||
| public int Source { get; set; } | ||
| } |
34 changes: 34 additions & 0 deletions
34
...Core/OData/test/Asp.Versioning.OData.ApiExplorer.Tests/Simulators/V1/RecordsController.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| // Copyright (c) .NET Foundation and contributors. All rights reserved. | ||
|
|
||
| namespace Asp.Versioning.Simulators.V1; | ||
|
|
||
| using Asp.Versioning.Simulators.Models; | ||
| using Microsoft.AspNetCore.Mvc; | ||
| using Microsoft.AspNetCore.OData.Routing.Controllers; | ||
| using static Microsoft.AspNetCore.Http.StatusCodes; | ||
|
|
||
| /// <summary> | ||
| /// Represents a RESTful record service. | ||
| /// </summary> | ||
| [ApiVersion( 1.0 )] | ||
| public class RecordsController : ODataController | ||
| { | ||
| /// <summary> | ||
| /// Gets a single record. | ||
| /// </summary> | ||
| /// <param name="id">The record identifier.</param> | ||
| /// <param name="source">The record source identifier.</param> | ||
| /// <returns>The requested record.</returns> | ||
| /// <response code="200">The record was successfully retrieved.</response> | ||
| /// <response code="404">The record does not exist.</response> | ||
| [HttpGet( "api/Records(id={id}, source={source})" )] | ||
| [Produces( "application/json" )] | ||
| [ProducesResponseType( typeof( Record ), Status200OK )] | ||
| [ProducesResponseType( Status404NotFound )] | ||
| public IActionResult Get( string id, int source ) => | ||
| Ok( new Record() | ||
| { | ||
| Id = id, | ||
| Source = source, | ||
| } ); | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check notice
Code scanning / CodeQL
Missed opportunity to use Where Note
Copilot Autofix
AI 1 day ago
In general terms, to fix this, replace the explicit in-loop if-statement filtering (
if (condition) { ... }) with filtration of the enumeration using LINQ'sWherebefore entering the loop. Specifically, for the loop at line 538:should become:
This makes it clear that we're only iterating over parameters with
Type.IsString(). To implement the change, you'll need to addusing System.Linq;if it's not already present. Only code shown may be modified: you may add the import at the top if and only if it's missing in the lines shown.