Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ignatandrei/RSCG_WhatIAmDoing
Instrument C# software on CI to find what the software is doing
https://github.com/ignatandrei/RSCG_WhatIAmDoing
Last synced: about 1 month ago
JSON representation
Instrument C# software on CI to find what the software is doing
- Host: GitHub
- URL: https://github.com/ignatandrei/RSCG_WhatIAmDoing
- Owner: ignatandrei
- License: mit
- Created: 2024-01-14T07:00:25.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2024-07-09T22:03:56.000Z (5 months ago)
- Last Synced: 2024-11-01T05:17:45.494Z (about 1 month ago)
- Language: C#
- Size: 125 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- RSCG_Examples - https://github.com/ignatandrei/RSCG_WhatIAmDoing
README
# RSCG_WhatIAmDoing
Instrument C# software on CI to find what the software is doing.
# Introduction
Decide what you want to monitor ... and then monitor it.
# Example
## Packages
Add the following into the csproj you want to be monitores
```xml
true
$(BaseIntermediateOutputPath)\GX
$(InterceptorsPreviewNamespaces);RSCG_InterceptorTemplate```
## Code
### Intercept static methods
Assume that you want to monitor all calls to System.Console```csharp
//[ExposeClass(typeof(Encoding), nameof(Encoding.EncodingName))]
//[InterceptStatic("System.IO.File.*ts")]
//[InterceptStatic("System.IO.File.*")]
[InterceptStatic("System.Console.*")] // regex
//[InterceptStatic("WIAD_DemoConsole.Fib.*")]
internal class InterceptorMethodStatic : InterceptorMethodStaticBase, IInterceptorMethodStatic
{
}
```### Intercept instance methods
Assume that you want to monitor all calls to any method of any instance of Person
```csharp
//[InterceptInstanceClass(typeof(Person),"ame")]
//[InterceptInstanceClass(typeof(Person), "parat")]
//[InterceptInstanceClass(typeof(Person), "ncodi")]
[InterceptInstanceClass(typeof(Person), ".*")] //regex
public class InterceptorMethodInstanceClass: InterceptorMethodInstanceClassBase, IInterceptorMethodInstanceClass
{
public InterceptorMethodInstanceClass()
{
}}
```### See the results
```csharp
var data= CachingData.Methods().ToArray();foreach (var item in data)
{
WriteLine($"Method {item.typeAndMethodData.MethodName} from class {item.typeAndMethodData.TypeOfClass} Time: {item.StartedAtDate} state {item.State} ");
WriteLine($" =>Arguments: {item.ArgumentsAsString()}");
if ((item.State & AccumulatedStateMethod.HasResult) == AccumulatedStateMethod.HasResult)
{
WriteLine($" =>Result: {item.Result}");
}}
```
# More details
If you want to implement YOUR interception , implement the following interfaces
IInterceptorMethodInstanceClass
IInterceptorMethodStatic
# License
MIT