Comments (5)
If your NotEmpty
and FileExist
are advices, it means they are classes. If you apply Priority
to them, you don’t need to do anything else. Each time those two will be applied somewhere (class, parameter…), they will be sorted so NotEmpty
will be processed first. If not, that’s a bug
from mradvice.
Hi. Unfortunately .NET does not guarantee attributes order, this is why Mr. Advice has the [Priority]
attribute you’ve always dreamed of
Apply it to your advices, specify a value (higher value means higher priority). See https://github.com/ArxOne/MrAdvice/wiki/ImplementingAdvices#markers-for-advices for a few more details.
from mradvice.
Many thanks for your answer which explains the behavior of .NET. I just had a look into it and noticed that it is only applicable on class and structs. Is there a way to support the priority of attributes on parameters?
from mradvice.
Priority is on advices, so apply it on advices, and apply advices to your parameters.
from mradvice.
I am aware that the priority is on advices, but as I mentioned before is that the usage is limited to only classes and structs, which is also stated in the PriorityAttribute.cs Code:
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct)]
public class PriorityAttribute : Attribute
With the example from beginning: DoSomethingWithAFile([NotEmpty(2)][FileExist(1)] string filepath) (Now with the priority)
I have implemented the priority attribute via inheritance, with the change of the target to AttributeTargets.Parameter without any different results, except the removal of the error message and the same behavior in random order.
Therefore it gives an error if applied on parameter scope. The limited target must be there for some reason and I don't know if I am missing something here.
Many thanks for your reply in advance and sorry for the inconvenience.
from mradvice.
Related Issues (20)
- Targeting assembly advice not working correctly HOT 1
- Question: perfomance. HOT 1
- AssemblyName starting with "Microsoft." skipped by Mr.Advice HOT 3
- build error in x64 with IMethodWeavingAdvice HOT 2
- Parameter for Parameter Advice HOT 2
- Example - Advice for Event handlers HOT 6
- Failed to emit module HOT 4
- dotnet publish throw exception when use --self-contained HOT 8
- Add Changelog HOT 2
- Failed to resolve assembly: System.Private.CoreLib, Version=5.0.0.0 HOT 20
- Dotnet core DI and logging HOT 6
- Incorrect version in MrAdvice.dll HOT 11
- MrAdvice.Weaver.exe fails on Visual Studio 2017 HOT 2
- MrAdviceWeaverPath not defined in Xamarin.Android project HOT 8
- dotnet build on linux build agents
- Containerize the solution in linux with .NET Core 3.1 HOT 4
- Crash when weaving in azure linux build agent .net 6 HOT 4
- StackTraceHiddenAttribute
- Support for .NET 7 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mradvice.