Comments (4)
Getter and setter have a [CompilerGeneratedAttribute]
. The only thing to do is to find the attribute, then analyze the body code to find the backing field, then remove backing field and do not emit any method.
The advice marker could be a special priority level (such as -1
?)
from mradvice.
Getter
Generated code with Roslyn:
IL_0000: ldarg.0
IL_0001: ldfld bool MethodLevelTest.AdvisedClass::'<UnadvisedAutoProperty>k__BackingField'
IL_0006: ret
With legacy C# compiler:
IL_0000: ldarg.0
IL_0001: ldfld bool MethodLevelTest.AdvisedClass::'<UnadvisedAutoProperty>k__BackingField'
IL_0006: stloc.0
IL_0007: br.s IL_0009
IL_0009: ldloc.0
IL_000a: ret
Setter
Same thing for both compilers:
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: stfld bool MethodLevelTest.AdvisedClass::'<UnadvisedAutoProperty>k__BackingField'
IL_0007: ret
from mradvice.
It's probably better to use another marker than [Priority]
, which is not explicit enough. Something like [AbstractTarget]
which means the original body and references can be removed (this may also work for methods).
from mradvice.
Done (v0.10). However, with C#6 property initializers, there is an incompatibility: since backing storage is removed, initialization from ctor() is then ignored.
from mradvice.
Related Issues (20)
- 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
- Wrong order of advices in class libraries HOT 5
- 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
- NullReferenceException on build
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.