postsharp / metalama.community Goto Github PK
View Code? Open in Web Editor NEWLicense: Other
License: Other
If a method has a parameter of some type other than CancellationToken
which happens to be named cancellationToken
, the weaver will correctly add a parameter of type CancellationToken
, but with the same name as the existing parameter. The weaver should choose a different parameter name to avoid the conflict. I am working on a fix for this.
Example:
Original:
// After transformation, MakeRequest should contain a CancellationToken parameter, and the call to client.GetAsync
// should include this argument. The weaver must choose a name other than "cancellationToken" for the added parameter.
public static async Task MakeRequest_ParameterNameCollision( HttpClient client, int cancellationToken )
{
await client.GetAsync( "https://httpbin.org/delay/5" );
}
Transformed (current behaviour):
// After transformation, MakeRequest should contain a CancellationToken parameter, and the call to client.GetAsync
// should include this argument. The weaver must choose a name other than "cancellationToken" for the added parameter.
public static async Task MakeRequest_ParameterNameCollision( HttpClient client, int cancellationToken, CancellationToken cancellationToken )
{
await client.GetAsync( "https://httpbin.org/delay/5", cancellationToken );
}
Transformed (desired behaviour):
// After transformation, MakeRequest should contain a CancellationToken parameter, and the call to client.GetAsync
// should include this argument. The weaver must choose a name other than "cancellationToken" for the added parameter.
public static async Task MakeRequest_ParameterNameCollision( HttpClient client, int cancellationToken, CancellationToken cancellationToken2 )
{
await client.GetAsync( "https://httpbin.org/delay/5", cancellationToken2 );
}
Example:
Original:
public static async Task MakeRequests_MultipleCtParams( CancellationToken ct1, CancellationToken ct2 )
{
using var client = new HttpClient();
// After transformation, the call to MakeRequest should *not* include a CancellationToken, because
// the containing method has two or more CancellationToken parameters.
await MakeRequest( client );
...
Transformed:
public static async Task MakeRequests_MultipleCtParams( CancellationToken ct1, CancellationToken ct2 )
{
using var client = new HttpClient();
// After transformation, the call to MakeRequest should *not* include a CancellationToken, because
// the containing method has two or more CancellationToken parameters.
await MakeRequest( client, ct2 );
...
The documented behaviour is that CancellationToken
arguments should not be added when the containing method has more than one CancellationToken
parameter. I am working on a fix for this.
CONTRIBUTING.md requires that all code follow the style guidelines, and that code may be automatically reformatted into compliance. Sometimes code to be transformed by Metalama.Testing.AspectTesting
unit tests must not follow the style guidelines because the test is covering some specific style-inconsistent scenario. How should this be handled? Is it ok to use // ReSharper disable All
in these files?
Might I also note that, as currently configured, .\Build.ps1 codestyle inspect
is very noisy for typical coding patterns that occur in aspect test code. Is there some scope for reducing the noise by default for unit test projects?
eg, a CONTRIBUTING.md
or similar.
Most (all?) the source files herein have a header like:
// Copyright (c) SharpCrafters s.r.o. See the LICENSE.md file in the root directory of this repository root for details.
How should this be handled when making 3rd party contributions?
Example:
Original:
private static async Task MakeRequest_FinalParamterIsParamsArray( HttpClient client, params object[] args )
{
...
}
Transformed:
private static async Task MakeRequest_FinalParamterIsParamsArray( HttpClient client, params object[] args, CancellationToken cancellationToken )
{
...
}
The transformed code is not valid C#. I am working on a fix.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.