├── Samples ├── Resource.txt ├── InfoOfSample │ ├── InternalClass.cs │ └── InfoOfSample.cs ├── AssemblyInfo.cs ├── PublicizeTarget.cs ├── AnotarNLogSample │ ├── ModuleInitializer.cs │ ├── ActionTarget.cs │ ├── NLogExplicitSample.cs │ ├── NLogExceptionSample.cs │ └── LogCaptureBuilder.cs ├── AnotarSerilogSample │ ├── ModuleInitializer.cs │ ├── EventSink.cs │ ├── SerilogExplicitSample.cs │ ├── LogCaptureBuilder.cs │ ├── LogEventExtensions.cs │ └── SerilogExceptionSample.cs ├── AnotarSplatSample │ ├── ModuleInitializer.cs │ ├── SplatExplicitSample.cs │ ├── SplatExceptionSample.cs │ ├── LogCaptureBuilder.cs │ └── Logger.cs ├── AnotarCommonLoggingSample │ ├── ModuleInitializer.cs │ ├── LogCaptureBuilder.cs │ ├── Log4NetExplicitSample.cs │ ├── CommonLoggingExceptionSample.cs │ └── ActionAppender.cs ├── AnotarCustomSample │ ├── LoggerFactory.cs │ ├── LogEntry.cs │ ├── CustomExplicitSample.cs │ ├── CustomExceptionSample.cs │ └── Logger.cs ├── AsyncErrorHandler.cs ├── CaselessSample.cs ├── ResourcerSample.cs ├── MethodTimerSample.cs ├── VirtuositySample.cs ├── ValidarSample │ ├── PersonValidator.cs │ ├── Person.cs │ ├── ValidationFactory.cs │ ├── ValidarSample.cs │ └── ValidationTemplate.cs ├── BasicFodyAddinSample.cs ├── AnotarCatelSample │ ├── ActionAppender.cs │ └── CatelSample.cs ├── EmptyConstructorSample.cs ├── ConfigureAwaitSample.cs ├── ModuleInitSample.cs ├── InoadSample.cs ├── VisualizeSample.cs ├── AsyncErrorHandlerSample.cs ├── EquatableSample.cs ├── FodyWeavers.xml ├── ExtraConstraintsSample │ ├── DelegateConstraintSample.cs │ └── EnumConstraintSample.cs ├── ObsoleteSample.cs ├── PropertyChangingSample.cs ├── PropertyChangedSample.cs ├── JanitorSample.cs ├── PublicizeSample.cs ├── Samples.csproj └── FodyWeavers.xsd ├── global.json ├── readme.md ├── CosturaAssemblyToReference ├── ClassInReferenceAssembly.cs └── CosturaAssemblyToReference.csproj ├── InlineILSample ├── FodyWeavers.xml ├── ZeroInit.cs ├── Sample.cs ├── InlineILSample.csproj └── FodyWeavers.xsd ├── ThrottleSample ├── FodyWeavers.xml ├── ThrottleSample.csproj ├── FodyWeavers.xsd └── Sample.cs ├── LocalsInitSample ├── FodyWeavers.xml ├── Program.cs ├── LocalsInitSample.csproj ├── StackallocBenchmark.cs └── FodyWeavers.xsd ├── SubstituteSample ├── FodyWeavers.xml ├── SampleForm.cs ├── Sample.cs ├── FodyWeavers.xsd ├── Substitutes.cs ├── SubstituteSample.csproj ├── SampleForm.Designer.cs ├── Properties │ ├── Resources.Designer.cs │ ├── Resources.de.resx │ └── Resources.resx ├── SampleForm.de.resx └── SampleForm.resx ├── CatelSample ├── FodyWeavers.xml ├── Sample.cs ├── CatelSample.csproj └── FodyWeavers.xsd ├── NullGuardSample ├── FodyWeavers.xml ├── Sample.cs ├── NullGuardSample.csproj └── FodyWeavers.xsd ├── ToStringSample ├── FodyWeavers.xml ├── ToStringSample.csproj ├── Sample.cs └── FodyWeavers.xsd ├── WeakEventHandlerSample ├── FodyWeavers.xml ├── EventSource.cs ├── WeakEventHandlerSample.csproj ├── EventSink.cs ├── FodyWeavers.xsd └── Test.cs ├── CosturaSample ├── FodyWeavers.xml ├── AssemblyLocation.cs ├── Sample.cs ├── CosturaSample.csproj └── FodyWeavers.xsd ├── MethodDecoratorSample ├── FodyWeavers.xml ├── Target.cs ├── InterceptionRecorder.cs ├── MethodDecoratorSample.csproj ├── InterceptorAttribute.cs ├── Sample.cs └── FodyWeavers.xsd ├── ReactiveUISample ├── FodyWeavers.xml ├── ReactiveUISample.csproj ├── ReactiveUISample.cs └── FodyWeavers.xsd ├── InSolutionWeaving ├── FodyWeavers.xml ├── InSolutionSample.cs ├── InSolutionWeaving.csproj └── FodyWeavers.xsd ├── Weavers ├── Weavers.csproj ├── NamedWeaver.cs └── ModuleWeaver.cs ├── .github ├── workflows │ └── merge-dependabot.yml └── dependabot.yml ├── appveyor.yml ├── .gitattributes ├── Directory.Build.props ├── .travis.yml ├── license.txt ├── .gitignore ├── .editorconfig ├── FodyAddinSamples.sln └── FodyAddinSamples.sln.DotSettings /Samples/Resource.txt: -------------------------------------------------------------------------------- 1 | Hello -------------------------------------------------------------------------------- /Samples/InfoOfSample/InternalClass.cs: -------------------------------------------------------------------------------- 1 | class InternalClass 2 | { 3 | internal void Method() 4 | { 5 | 6 | } 7 | } -------------------------------------------------------------------------------- /global.json: -------------------------------------------------------------------------------- 1 | { 2 | "sdk": { 3 | "version": "8.0.101", 4 | "allowPrerelease": true, 5 | "rollForward": "latestFeature" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /Samples/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | [assembly: Janitor.SkipWeavingNamespace("Samples.Logging.LogProviders")] 2 | [assembly: Janitor.SkipWeavingNamespace("MimickSample")] -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | ![Icon](https://raw.github.com/Fody/Fody/master/package_icon.png) 2 | 3 | ## A working sample for each [Fody](https://github.com/Fody/Home/) Addin -------------------------------------------------------------------------------- /CosturaAssemblyToReference/ClassInReferenceAssembly.cs: -------------------------------------------------------------------------------- 1 | public class ClassInReferenceAssembly 2 | { 3 | public static string SayHello() => 4 | "Hello World"; 5 | } -------------------------------------------------------------------------------- /InlineILSample/FodyWeavers.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /ThrottleSample/FodyWeavers.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /LocalsInitSample/FodyWeavers.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /SubstituteSample/FodyWeavers.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /CatelSample/FodyWeavers.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /LocalsInitSample/Program.cs: -------------------------------------------------------------------------------- 1 | using BenchmarkDotNet.Running; 2 | 3 | public static class Program 4 | { 5 | public static void Main() 6 | => BenchmarkRunner.Run(); 7 | } -------------------------------------------------------------------------------- /Samples/PublicizeTarget.cs: -------------------------------------------------------------------------------- 1 | class PublicizeTarget 2 | { 3 | // ReSharper disable UnusedMember.Local 4 | void Method() 5 | // ReSharper restore UnusedMember.Local 6 | { 7 | } 8 | } -------------------------------------------------------------------------------- /NullGuardSample/FodyWeavers.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /SubstituteSample/SampleForm.cs: -------------------------------------------------------------------------------- 1 | using System.Windows.Forms; 2 | 3 | public partial class SampleForm: Form 4 | { 5 | public SampleForm() 6 | { 7 | InitializeComponent(); 8 | } 9 | } -------------------------------------------------------------------------------- /ToStringSample/FodyWeavers.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /Samples/AnotarNLogSample/ModuleInitializer.cs: -------------------------------------------------------------------------------- 1 | namespace AnotarNLogSample; 2 | 3 | public static class ModuleInitializer 4 | { 5 | public static void Initialize() => 6 | LogCaptureBuilder.Init(); 7 | } -------------------------------------------------------------------------------- /CosturaAssemblyToReference/CosturaAssemblyToReference.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | net48;net8.0 4 | 5 | 6 | -------------------------------------------------------------------------------- /Samples/AnotarSerilogSample/ModuleInitializer.cs: -------------------------------------------------------------------------------- 1 | namespace AnotarSerilogSample; 2 | 3 | public static class ModuleInitializer 4 | { 5 | public static void Initialize() => 6 | LogCaptureBuilder.Init(); 7 | } -------------------------------------------------------------------------------- /Samples/AnotarSplatSample/ModuleInitializer.cs: -------------------------------------------------------------------------------- 1 | namespace AnotarSplatSample; 2 | 3 | public static class ModuleInitializer 4 | { 5 | public static void Initialize() => 6 | LogCaptureBuilder.Init(); 7 | } -------------------------------------------------------------------------------- /WeakEventHandlerSample/FodyWeavers.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /CosturaSample/FodyWeavers.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /Samples/AnotarCommonLoggingSample/ModuleInitializer.cs: -------------------------------------------------------------------------------- 1 | namespace AnotarCommonLoggingSample; 2 | 3 | public static class ModuleInitializer 4 | { 5 | public static void Initialize() => 6 | LogCaptureBuilder.Init(); 7 | } -------------------------------------------------------------------------------- /Samples/AnotarCustomSample/LoggerFactory.cs: -------------------------------------------------------------------------------- 1 | 2 | // ReSharper disable UnusedTypeParameter 3 | namespace AnotarCustomSample; 4 | 5 | public class LoggerFactory 6 | { 7 | public static Logger GetLogger() => 8 | new(); 9 | } -------------------------------------------------------------------------------- /Samples/AnotarCustomSample/LogEntry.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace AnotarCustomSample; 4 | 5 | public class LogEntry 6 | { 7 | public string Format; 8 | public object[] Params; 9 | public Exception Exception; 10 | } -------------------------------------------------------------------------------- /MethodDecoratorSample/FodyWeavers.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Samples/AsyncErrorHandler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | 4 | public static class AsyncErrorHandler 5 | { 6 | public static void HandleException(Exception exception) => 7 | Debug.WriteLine($"Exception occurred: {exception.Message}"); 8 | } -------------------------------------------------------------------------------- /ReactiveUISample/FodyWeavers.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | -------------------------------------------------------------------------------- /Samples/CaselessSample.cs: -------------------------------------------------------------------------------- 1 | using Xunit; 2 | 3 | public class CaselessSample 4 | { 5 | [Fact] 6 | public void Run() 7 | { 8 | var string1 = "sample_string"; 9 | var string2 = "Sample_String"; 10 | Assert.True(string2 == string1); 11 | } 12 | } -------------------------------------------------------------------------------- /Samples/ResourcerSample.cs: -------------------------------------------------------------------------------- 1 | using Xunit; 2 | using Resourcer; 3 | 4 | public class ResourcerSample 5 | { 6 | [Fact] 7 | public void Run() 8 | { 9 | var fromResource = Resource.AsString("Resource.txt"); 10 | Assert.Equal("Hello", fromResource); 11 | } 12 | } -------------------------------------------------------------------------------- /InSolutionWeaving/FodyWeavers.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Samples/MethodTimerSample.cs: -------------------------------------------------------------------------------- 1 | using System.Threading; 2 | using MethodTimer; 3 | using Xunit; 4 | 5 | public class MethodTimerSample 6 | { 7 | [Fact] 8 | [Time] 9 | public void MyMethod() => 10 | //Run and have a look in the debug window 11 | Thread.Sleep(1500); 12 | } -------------------------------------------------------------------------------- /MethodDecoratorSample/Target.cs: -------------------------------------------------------------------------------- 1 | [module:Interceptor] 2 | 3 | public static class Target 4 | { 5 | [Interceptor] 6 | public static void MyMethod() 7 | { 8 | 9 | } 10 | 11 | [Interceptor] 12 | public static void MyExceptionMethod() => 13 | throw new("Foo"); 14 | } 15 | -------------------------------------------------------------------------------- /MethodDecoratorSample/InterceptionRecorder.cs: -------------------------------------------------------------------------------- 1 | public static class InterceptionRecorder 2 | { 3 | public static bool OnEntryCalled; 4 | public static bool OnExitCalled; 5 | public static bool OnExceptionCalled; 6 | 7 | public static void Clear() => 8 | OnExitCalled= OnEntryCalled = OnExceptionCalled = false; 9 | } -------------------------------------------------------------------------------- /Samples/VirtuositySample.cs: -------------------------------------------------------------------------------- 1 | using Xunit; 2 | 3 | public class VirtuositySample 4 | { 5 | [Fact] 6 | public void Run() => 7 | Assert.True(typeof(Target).GetProperty("Property")!.GetMethod.IsVirtual); 8 | 9 | public class Target 10 | { 11 | public string Property { get; set; } 12 | } 13 | } -------------------------------------------------------------------------------- /Samples/AnotarSerilogSample/EventSink.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Serilog.Core; 3 | using Serilog.Events; 4 | 5 | namespace AnotarSerilogSample; 6 | 7 | public sealed class EventSink : ILogEventSink 8 | { 9 | public Action Action; 10 | public void Emit(LogEvent logEvent) => 11 | Action(logEvent); 12 | } -------------------------------------------------------------------------------- /Samples/AnotarNLogSample/ActionTarget.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using NLog; 3 | using NLog.Targets; 4 | 5 | namespace AnotarNLogSample; 6 | 7 | public sealed class ActionTarget : Target 8 | { 9 | public Action Action; 10 | 11 | protected override void Write(LogEventInfo logEvent) => 12 | Action(logEvent); 13 | } -------------------------------------------------------------------------------- /Samples/ValidarSample/PersonValidator.cs: -------------------------------------------------------------------------------- 1 | using FluentValidation; 2 | 3 | namespace ValidarSample; 4 | 5 | public class PersonValidator : 6 | AbstractValidator 7 | { 8 | public PersonValidator() 9 | { 10 | RuleFor(_ => _.FamilyName).NotEmpty(); 11 | RuleFor(_ => _.GivenNames).NotEmpty(); 12 | } 13 | } -------------------------------------------------------------------------------- /WeakEventHandlerSample/EventSource.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace WeakEventHandlerSample; 4 | 5 | public class EventSource 6 | { 7 | public event EventHandler Event; 8 | 9 | public void OnEvent() => 10 | Event?.Invoke(this, EventArgs.Empty); 11 | 12 | public bool HasEventHandlersAttached => Event != null; 13 | } -------------------------------------------------------------------------------- /Samples/AnotarCommonLoggingSample/LogCaptureBuilder.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Common.Logging; 3 | 4 | namespace AnotarCommonLoggingSample; 5 | 6 | public static class LogCaptureBuilder 7 | { 8 | [ThreadStatic] 9 | public static string LastMessage; 10 | 11 | public static void Init() => 12 | LogManager.Adapter = new ActionAdapter(); 13 | } -------------------------------------------------------------------------------- /Weavers/Weavers.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | netstandard2.0 4 | true 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /InlineILSample/ZeroInit.cs: -------------------------------------------------------------------------------- 1 | using static InlineIL.IL.Emit; 2 | 3 | public static class ZeroInit 4 | { 5 | public static void InitStruct(ref T value) 6 | where T : struct 7 | { 8 | Ldarg(nameof(value)); 9 | 10 | Ldc_I4_0(); 11 | 12 | Sizeof(typeof(T)); 13 | 14 | Unaligned(1); 15 | Initblk(); 16 | } 17 | } -------------------------------------------------------------------------------- /Samples/BasicFodyAddinSample.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Xunit; 3 | 4 | public class BasicFodyAddinSample 5 | { 6 | [Fact] 7 | public void Run() 8 | { 9 | var type = GetType().Assembly.GetType("Hello")!; 10 | var instance = (dynamic) Activator.CreateInstance(type)!; 11 | Assert.Equal("Hello World", instance.World()); 12 | } 13 | } -------------------------------------------------------------------------------- /Samples/ValidarSample/Person.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel; 2 | using Validar; 3 | 4 | namespace ValidarSample; 5 | 6 | [InjectValidation] 7 | public class Person : 8 | INotifyPropertyChanged 9 | { 10 | public string GivenNames { get; set; } 11 | public string FamilyName { get; set; } 12 | public event PropertyChangedEventHandler PropertyChanged; 13 | } -------------------------------------------------------------------------------- /Samples/AnotarCatelSample/ActionAppender.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Catel.Logging; 3 | 4 | namespace AnotarCatelSample; 5 | 6 | public class LogListener : 7 | LogListenerBase 8 | { 9 | public Action Action; 10 | 11 | protected override void Write(ILog log, string message, LogEvent logEvent, object extraData, LogData logData, DateTime time) => 12 | Action(message, logEvent); 13 | } -------------------------------------------------------------------------------- /CosturaSample/AssemblyLocation.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | 4 | public static class AssemblyLocation 5 | { 6 | public static string CurrentDirectory() 7 | { 8 | var assembly = typeof(AssemblyLocation).Assembly; 9 | var uri = new UriBuilder(assembly.CodeBase); 10 | var path = Uri.UnescapeDataString(uri.Path); 11 | 12 | return Path.GetDirectoryName(path); 13 | } 14 | } -------------------------------------------------------------------------------- /NullGuardSample/Sample.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Xunit; 3 | 4 | public class NullGuardSample 5 | { 6 | [Fact(Skip = "Explicit")] 7 | public void Run() 8 | { 9 | var targetClass = new TargetClass(); 10 | Assert.Throws(() => targetClass.Method(null)); 11 | } 12 | } 13 | 14 | public class TargetClass 15 | { 16 | public void Method(string param) 17 | { 18 | } 19 | } -------------------------------------------------------------------------------- /Samples/AnotarNLogSample/NLogExplicitSample.cs: -------------------------------------------------------------------------------- 1 | using Anotar.NLog; 2 | using Xunit; 3 | 4 | namespace AnotarNLogSample; 5 | 6 | public class NLogExplicitSample 7 | { 8 | [Fact] 9 | public void Run() 10 | { 11 | MyMethod(); 12 | 13 | Assert.Equal("Method: 'Void MyMethod()'. Line: ~17. TheMessage", LogCaptureBuilder.LastMessage); 14 | } 15 | 16 | static void MyMethod() => 17 | LogTo.Debug("TheMessage"); 18 | } -------------------------------------------------------------------------------- /Samples/EmptyConstructorSample.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Xunit; 3 | 4 | // ReSharper disable once UnusedParameter.Local 5 | public class EmptyConstructorSample 6 | { 7 | [Fact] 8 | public void Run() 9 | { 10 | var target = Activator.CreateInstance(); 11 | Assert.NotNull(target); 12 | } 13 | 14 | public class Target 15 | { 16 | public Target(int foo) 17 | { 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /.github/workflows/merge-dependabot.yml: -------------------------------------------------------------------------------- 1 | name: merge-dependabot 2 | on: 3 | pull_request: 4 | jobs: 5 | automerge: 6 | runs-on: ubuntu-latest 7 | if: github.actor == 'dependabot[bot]' 8 | steps: 9 | - name: Dependabot Auto Merge 10 | uses: ahmadnassri/action-dependabot-auto-merge@v2.6.6 11 | with: 12 | target: minor 13 | github-token: ${{ secrets.GITHUB_TOKEN }} 14 | command: squash and merge -------------------------------------------------------------------------------- /Samples/AnotarCustomSample/CustomExplicitSample.cs: -------------------------------------------------------------------------------- 1 | using Anotar.Custom; 2 | using Xunit; 3 | 4 | namespace AnotarCustomSample; 5 | 6 | public class CustomExplicitSample 7 | { 8 | [Fact] 9 | public void Run() 10 | { 11 | MyMethod(); 12 | 13 | Assert.Equal("Method: 'Void MyMethod()'. Line: ~17. TheMessage", Logger.LastMessage.Format); 14 | } 15 | 16 | static void MyMethod() => 17 | LogTo.Debug("TheMessage"); 18 | } -------------------------------------------------------------------------------- /Samples/AnotarSplatSample/SplatExplicitSample.cs: -------------------------------------------------------------------------------- 1 | using Anotar.Splat; 2 | using Xunit; 3 | 4 | namespace AnotarSplatSample; 5 | 6 | public class SplatExplicitSample 7 | { 8 | [Fact] 9 | public void Run() 10 | { 11 | MyMethod(); 12 | 13 | Assert.Equal("Method: 'Void MyMethod()'. Line: ~17. TheMessage", LogCaptureBuilder.LastMessage); 14 | } 15 | 16 | static void MyMethod() => 17 | LogTo.Debug("TheMessage"); 18 | } -------------------------------------------------------------------------------- /Samples/ConfigureAwaitSample.cs: -------------------------------------------------------------------------------- 1 | using System.Threading; 2 | using System.Threading.Tasks; 3 | using Fody; 4 | using Xunit; 5 | 6 | [ConfigureAwait(false)] 7 | public class ConfigureAwaitSample 8 | { 9 | [Fact] 10 | public async Task Run() 11 | { 12 | var beforeAwaitId = Thread.CurrentThread.ManagedThreadId; 13 | await Task.Delay(30); 14 | Assert.NotEqual(Thread.CurrentThread.ManagedThreadId, beforeAwaitId); 15 | } 16 | } -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | image: Visual Studio 2022 2 | environment: 3 | DOTNET_NOLOGO: true 4 | DOTNET_CLI_TELEMETRY_OPTOUT: true 5 | DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true 6 | build_script: 7 | - pwsh: | 8 | Invoke-WebRequest "https://dot.net/v1/dotnet-install.ps1" -OutFile "./dotnet-install.ps1" 9 | ./dotnet-install.ps1 -JSonFile global.json -Architecture x64 -InstallDir 'C:\Program Files\dotnet' 10 | - dotnet build --configuration Release 11 | test: off 12 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: nuget 4 | directory: "/" 5 | schedule: 6 | interval: daily 7 | open-pull-requests-limit: 10 8 | ignore: 9 | - dependency-name: FluentValidation 10 | versions: 11 | - 10.0.0 12 | - 10.0.1 13 | - 10.0.2 14 | - 10.0.3 15 | - dependency-name: Costura.Fody 16 | versions: 17 | - 5.0.2 18 | - dependency-name: Catel.Core 19 | versions: 20 | - 5.12.12 21 | -------------------------------------------------------------------------------- /Samples/ModuleInitSample.cs: -------------------------------------------------------------------------------- 1 | using Xunit; 2 | 3 | public class ModuleInitSample 4 | { 5 | [Fact] 6 | public void Run() => 7 | //ModuleInitializer.Initialize will have been called when this assembly was loaded. 8 | Assert.True(ModuleInitializer.InitializeCalled); 9 | } 10 | 11 | public static class ModuleInitializer 12 | { 13 | public static void Initialize() => 14 | InitializeCalled = true; 15 | 16 | public static bool InitializeCalled; 17 | } -------------------------------------------------------------------------------- /Samples/AnotarCommonLoggingSample/Log4NetExplicitSample.cs: -------------------------------------------------------------------------------- 1 | using Anotar.CommonLogging; 2 | using Xunit; 3 | 4 | namespace AnotarCommonLoggingSample; 5 | 6 | public class CommonLoggingExplicitSample 7 | { 8 | [Fact] 9 | public void Run() 10 | { 11 | MyMethod(); 12 | 13 | Assert.Equal("Method: 'Void MyMethod()'. Line: ~17. TheMessage", LogCaptureBuilder.LastMessage); 14 | } 15 | 16 | static void MyMethod() => 17 | LogTo.Debug("TheMessage"); 18 | } -------------------------------------------------------------------------------- /CatelSample/Sample.cs: -------------------------------------------------------------------------------- 1 | using Catel.Data; 2 | using Xunit; 3 | 4 | public class Sample 5 | { 6 | [Fact] 7 | public void Run() 8 | { 9 | var target = new Target(); 10 | var property1Changed = false; 11 | target.PropertyChanged += (_, _) => property1Changed = true; 12 | target.Property1 = "New Value"; 13 | Assert.True(property1Changed); 14 | } 15 | } 16 | 17 | public class Target: ModelBase 18 | { 19 | public string Property1 { get; set; } 20 | } -------------------------------------------------------------------------------- /InSolutionWeaving/InSolutionSample.cs: -------------------------------------------------------------------------------- 1 | using Xunit; 2 | 3 | public class InSolutionSample 4 | { 5 | [Fact] 6 | public void Run() 7 | { 8 | var assembly = typeof(InSolutionSample).Assembly; 9 | var typeInjectedByModuleWeaver = assembly.GetType("Weavers.TypeInjectedByModuleWeaver"); 10 | Assert.NotNull(typeInjectedByModuleWeaver); 11 | var typeInjectedByNamedWeaver = assembly.GetType("Weavers.TypeInjectedByNamedWeaver"); 12 | Assert.NotNull(typeInjectedByNamedWeaver); 13 | } 14 | } -------------------------------------------------------------------------------- /Samples/AnotarSplatSample/SplatExceptionSample.cs: -------------------------------------------------------------------------------- 1 | using Anotar.Splat; 2 | using Xunit; 3 | 4 | namespace AnotarSplatSample; 5 | 6 | public class SplatExceptionSample 7 | { 8 | [Fact] 9 | public void Run() 10 | { 11 | try 12 | { 13 | MyMethod(); 14 | } 15 | catch 16 | { 17 | } 18 | 19 | Assert.NotEmpty(LogCaptureBuilder.LastMessage); 20 | } 21 | 22 | [LogToDebugOnException] 23 | static void MyMethod() => 24 | throw new("Foo"); 25 | } -------------------------------------------------------------------------------- /Samples/AnotarSplatSample/LogCaptureBuilder.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Splat; 3 | 4 | namespace AnotarSplatSample; 5 | 6 | public class LogCaptureBuilder 7 | { 8 | [ThreadStatic] 9 | public static string LastMessage; 10 | 11 | static Logger currentLogger = new(); 12 | 13 | public static void Init() => 14 | Locator.CurrentMutable.Register(() => new FuncLogManager(GetLogger), typeof(ILogManager)); 15 | 16 | static IFullLogger GetLogger(Type arg) => 17 | new WrappingFullLogger(currentLogger); 18 | } -------------------------------------------------------------------------------- /InlineILSample/Sample.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Xunit; 3 | 4 | public class Sample 5 | { 6 | [Fact] 7 | public void Run() 8 | { 9 | var item = new MyStruct 10 | { 11 | Int = 42, 12 | Guid = Guid.NewGuid() 13 | }; 14 | 15 | ZeroInit.InitStruct(ref item); 16 | 17 | Assert.Equal(0, item.Int); 18 | Assert.Equal(Guid.Empty, item.Guid); 19 | } 20 | 21 | struct MyStruct 22 | { 23 | public int Int; 24 | public Guid Guid; 25 | } 26 | } -------------------------------------------------------------------------------- /LocalsInitSample/LocalsInitSample.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | net8.0 4 | Exe 5 | true 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Samples/InoadSample.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using Ionad; 4 | using Xunit; 5 | 6 | public class IonadSample 7 | { 8 | [Fact] 9 | public void Run() 10 | { 11 | DateTimeSubstitute.Current = new(2000, 1, 1); 12 | var time = DateTime.Now; 13 | Trace.WriteLine(time); 14 | } 15 | 16 | [StaticReplacement(typeof(DateTime))] 17 | public static class DateTimeSubstitute 18 | { 19 | public static DateTime Current; 20 | 21 | public static DateTime Now => Current; 22 | } 23 | } -------------------------------------------------------------------------------- /CosturaSample/Sample.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | using System.IO; 3 | using Xunit; 4 | 5 | public class CosturaSample 6 | { 7 | public CosturaSample() 8 | { 9 | var path = Path.Combine(AssemblyLocation.CurrentDirectory(), "CosturaAssemblyToReference.dll"); 10 | File.Delete(path); 11 | } 12 | 13 | [Fact] 14 | public void Run() => 15 | //Note that this will work even though CosturaAssemblyToReference.dll does not exists in the execution directory 16 | Debug.WriteLine(ClassInReferenceAssembly.SayHello()); 17 | } -------------------------------------------------------------------------------- /Samples/AnotarNLogSample/NLogExceptionSample.cs: -------------------------------------------------------------------------------- 1 | using Anotar.NLog; 2 | using Xunit; 3 | 4 | namespace AnotarNLogSample; 5 | 6 | public class NLogExceptionSample 7 | { 8 | [Fact] 9 | public void Run() 10 | { 11 | try 12 | { 13 | MyMethod(); 14 | } 15 | catch 16 | { 17 | } 18 | 19 | Assert.Equal("Exception occurred in 'Void MyMethod()'. ", LogCaptureBuilder.LastMessage); 20 | } 21 | 22 | [LogToDebugOnException] 23 | static void MyMethod() => 24 | throw new("Foo"); 25 | } -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text 3 | 4 | # Don't check these into the repo as LF to work around TeamCity bug 5 | *.xml -text 6 | *.targets -text 7 | 8 | # Custom for Visual Studio 9 | *.cs diff=csharp 10 | *.sln merge=union 11 | *.csproj merge=union 12 | *.vbproj merge=union 13 | *.fsproj merge=union 14 | *.dbproj merge=union 15 | 16 | # Denote all files that are truly binary and should not be modified. 17 | *.dll binary 18 | *.exe binary 19 | *.png binary 20 | *.ico binary 21 | *.snk binary 22 | *.pdb binary 23 | -------------------------------------------------------------------------------- /Samples/AnotarCustomSample/CustomExceptionSample.cs: -------------------------------------------------------------------------------- 1 | using Anotar.Custom; 2 | using Xunit; 3 | 4 | namespace AnotarCustomSample; 5 | 6 | public class CustomExceptionSample 7 | { 8 | [Fact] 9 | public void Run() 10 | { 11 | try 12 | { 13 | MyMethod(); 14 | } 15 | catch 16 | { 17 | } 18 | 19 | Assert.Equal("Exception occurred in 'Void MyMethod()'. ", Logger.LastMessage.Format); 20 | } 21 | 22 | [LogToDebugOnException] 23 | static void MyMethod() => 24 | throw new("Foo"); 25 | } -------------------------------------------------------------------------------- /Directory.Build.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | true 5 | preview 6 | CS0067;NU1701;CS0649 7 | direct 8 | full 9 | true 10 | preview 11 | true 12 | true 13 | 14 | 15 | -------------------------------------------------------------------------------- /Samples/AnotarCommonLoggingSample/CommonLoggingExceptionSample.cs: -------------------------------------------------------------------------------- 1 | using Anotar.CommonLogging; 2 | using Xunit; 3 | 4 | namespace AnotarCommonLoggingSample; 5 | 6 | public class CommonLoggingExceptionSample 7 | { 8 | [Fact] 9 | public void Run() 10 | { 11 | try 12 | { 13 | MyMethod(); 14 | } 15 | catch 16 | { 17 | } 18 | 19 | Assert.Equal("Exception occurred in 'Void MyMethod()'. ", LogCaptureBuilder.LastMessage); 20 | } 21 | 22 | [LogToDebugOnException] 23 | static void MyMethod() => 24 | throw new("Foo"); 25 | } -------------------------------------------------------------------------------- /Samples/AnotarSerilogSample/SerilogExplicitSample.cs: -------------------------------------------------------------------------------- 1 | using Anotar.Serilog; 2 | using Xunit; 3 | 4 | namespace AnotarSerilogSample; 5 | 6 | public class SerilogExplicitSample 7 | { 8 | [Fact] 9 | public void Run() 10 | { 11 | MyMethod(); 12 | 13 | var lastMessage = LogCaptureBuilder.LastMessage; 14 | Assert.Equal("Void MyMethod()", lastMessage.MethodName()); 15 | Assert.Equal(20, lastMessage.LineNumber()); 16 | Assert.Equal("TheMessage", lastMessage.MessageTemplate.Text); 17 | } 18 | 19 | static void MyMethod() => 20 | LogTo.Debug("TheMessage"); 21 | } -------------------------------------------------------------------------------- /Samples/AnotarSerilogSample/LogCaptureBuilder.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Serilog; 3 | using Serilog.Events; 4 | 5 | namespace AnotarSerilogSample; 6 | 7 | public static class LogCaptureBuilder 8 | { 9 | [ThreadStatic] 10 | public static LogEvent LastMessage; 11 | 12 | public static void Init() 13 | { 14 | var eventSink = new EventSink 15 | { 16 | Action = _ => LastMessage = _ 17 | }; 18 | Log.Logger = new LoggerConfiguration() 19 | .MinimumLevel.Verbose() 20 | .WriteTo.Sink(eventSink) 21 | .CreateLogger(); 22 | } 23 | 24 | } -------------------------------------------------------------------------------- /Samples/AnotarSerilogSample/LogEventExtensions.cs: -------------------------------------------------------------------------------- 1 | using Serilog.Events; 2 | 3 | namespace AnotarSerilogSample; 4 | 5 | public static class LogEventExtensions 6 | { 7 | public static string MethodName(this LogEvent logEvent) 8 | { 9 | var logEventPropertyValue = (ScalarValue) logEvent.Properties["MethodName"]; 10 | return (string) logEventPropertyValue.Value; 11 | } 12 | 13 | public static int LineNumber(this LogEvent logEvent) 14 | { 15 | var logEventPropertyValue = (ScalarValue) logEvent.Properties["LineNumber"]; 16 | return (int) logEventPropertyValue.Value; 17 | } 18 | } -------------------------------------------------------------------------------- /ToStringSample/ToStringSample.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | net48 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /InlineILSample/InlineILSample.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | net48;net8.0 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /MethodDecoratorSample/MethodDecoratorSample.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | net48;net8.0 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /NullGuardSample/NullGuardSample.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | net48;net8.0 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Samples/AnotarSerilogSample/SerilogExceptionSample.cs: -------------------------------------------------------------------------------- 1 | using Anotar.Serilog; 2 | using Xunit; 3 | 4 | namespace AnotarSerilogSample; 5 | 6 | public class SerilogExceptionSample 7 | { 8 | [Fact] 9 | public void Run() 10 | { 11 | try 12 | { 13 | MyMethod(); 14 | } 15 | catch 16 | { 17 | } 18 | 19 | var actual = LogCaptureBuilder.LastMessage.MessageTemplate.Text; 20 | Assert.Equal("Exception occurred in 'Void MyMethod()'. ", actual); 21 | } 22 | 23 | [LogToDebugOnException] 24 | static void MyMethod() => 25 | throw new("Foo"); 26 | } -------------------------------------------------------------------------------- /WeakEventHandlerSample/WeakEventHandlerSample.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | net48;net8.0 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Weavers/NamedWeaver.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Fody; 3 | using Mono.Cecil; 4 | 5 | public class NamedWeaver: BaseModuleWeaver 6 | { 7 | public override void Execute() 8 | { 9 | var type = GetType(); 10 | var typeDefinition = new TypeDefinition( 11 | @namespace: type.Assembly.GetName().Name, 12 | name: $"TypeInjectedBy{type.Name}", 13 | attributes: TypeAttributes.Public, 14 | baseType: TypeSystem.ObjectReference); 15 | ModuleDefinition.Types.Add(typeDefinition); 16 | } 17 | 18 | public override IEnumerable GetAssembliesForScanning() => []; 19 | } -------------------------------------------------------------------------------- /Weavers/ModuleWeaver.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Fody; 3 | using Mono.Cecil; 4 | 5 | public class ModuleWeaver: BaseModuleWeaver 6 | { 7 | public override void Execute() 8 | { 9 | var type = GetType(); 10 | var typeDefinition = new TypeDefinition( 11 | @namespace: type.Assembly.GetName().Name, 12 | name: $"TypeInjectedBy{type.Name}", 13 | attributes: TypeAttributes.Public, 14 | baseType: TypeSystem.ObjectReference); 15 | ModuleDefinition.Types.Add(typeDefinition); 16 | } 17 | 18 | public override IEnumerable GetAssembliesForScanning() => []; 19 | } -------------------------------------------------------------------------------- /Samples/VisualizeSample.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | using Xunit; 3 | 4 | public class VisualizeSample 5 | { 6 | [Fact] 7 | public void Run() 8 | { 9 | var person = new Person 10 | { 11 | FamilyName = "Smith", 12 | GivenNames = "John James" 13 | }; 14 | //Set a breakpoint here and look at person in the debugger 15 | Trace.WriteLine(person); 16 | } 17 | 18 | public class Person 19 | { 20 | public string GivenNames { get; set; } 21 | public string FamilyName { get; set; } 22 | 23 | public string FullName => $"{GivenNames} {FamilyName}"; 24 | } 25 | } -------------------------------------------------------------------------------- /Samples/AsyncErrorHandlerSample.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using Xunit; 3 | 4 | public class AsyncErrorHandlerSample 5 | { 6 | [Fact] 7 | public async Task Run() 8 | { 9 | try 10 | { 11 | 12 | var instance = new Target(); 13 | await instance.MethodWithThrow(); 14 | //run and have a look at the debug window 15 | } 16 | catch 17 | { 18 | } 19 | } 20 | 21 | public class Target 22 | { 23 | public async Task MethodWithThrow() 24 | { 25 | await Task.Delay(1); 26 | throw new("MyException"); 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /Samples/AnotarNLogSample/LogCaptureBuilder.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using NLog; 3 | using NLog.Config; 4 | 5 | namespace AnotarNLogSample; 6 | 7 | public class LogCaptureBuilder 8 | { 9 | [ThreadStatic] 10 | public static string LastMessage; 11 | 12 | public static void Init() 13 | { 14 | var actionTarget = new ActionTarget 15 | { 16 | Action = _ => LastMessage = _.Message 17 | }; 18 | var config = new LoggingConfiguration(); 19 | config.LoggingRules.Add(new("*", LogLevel.Trace, actionTarget)); 20 | config.AddTarget("debugger", actionTarget); 21 | LogManager.Configuration = config; 22 | } 23 | } -------------------------------------------------------------------------------- /WeakEventHandlerSample/EventSink.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace WeakEventHandlerSample; 4 | 5 | public class EventSink 6 | { 7 | EventSource source; 8 | Action eventTracer; 9 | 10 | public EventSink(EventSource source, Action eventTracer) 11 | { 12 | this.source = source; 13 | this.eventTracer = eventTracer; 14 | } 15 | 16 | public void Subscribe() => 17 | source.Event += Source_Event; 18 | 19 | public void Unsubscribe() => 20 | source.Event -= Source_Event; 21 | 22 | [WeakEventHandler.MakeWeak] 23 | void Source_Event(object sender, EventArgs e) => 24 | eventTracer("Event"); 25 | } -------------------------------------------------------------------------------- /CatelSample/CatelSample.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | net8.0 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /ReactiveUISample/ReactiveUISample.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | net48;net8.0 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /InSolutionWeaving/InSolutionWeaving.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | net48;net8.0 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /ReactiveUISample/ReactiveUISample.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using ReactiveUI; 3 | using ReactiveUI.Fody.Helpers; 4 | using Splat; 5 | using Xunit; 6 | 7 | public class ReactiveUiSample 8 | { 9 | [Fact] 10 | public void Run() 11 | { 12 | var target = new ReactiveViewModel(); 13 | var notificationOccured = false; 14 | target.WhenAnyValue(_ => _.Property).Subscribe(_ => notificationOccured = true); 15 | Assert.True(notificationOccured); 16 | } 17 | 18 | public IEnableLogger Foo { get; set; } 19 | 20 | public class ReactiveViewModel : 21 | ReactiveObject 22 | { 23 | [Reactive] 24 | public string Property { get; set; } 25 | } 26 | } -------------------------------------------------------------------------------- /CosturaSample/CosturaSample.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | net48 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /MethodDecoratorSample/InterceptorAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using MethodDecorator.Fody.Interfaces; 4 | 5 | [AttributeUsage(AttributeTargets.Method | AttributeTargets.Constructor | AttributeTargets.Module)] 6 | public class InterceptorAttribute : Attribute, IMethodDecorator 7 | { 8 | public void Init(object instance, MethodBase method, object[] args) 9 | { 10 | } 11 | 12 | public void OnEntry() => 13 | InterceptionRecorder.OnEntryCalled = true; 14 | 15 | public void OnExit() => 16 | InterceptionRecorder.OnExitCalled = true; 17 | 18 | public void OnException(Exception exception) => 19 | InterceptionRecorder.OnExceptionCalled = true; 20 | } 21 | -------------------------------------------------------------------------------- /Samples/EquatableSample.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Equatable; 3 | using Xunit; 4 | 5 | public class EquatableSample 6 | { 7 | [ImplementsEquatable] 8 | public class Target 9 | { 10 | [Equals] 11 | public string Property { get; set; } 12 | } 13 | 14 | [Fact] 15 | public void Run() 16 | { 17 | var left = new Target 18 | { 19 | Property = "Test", 20 | }; 21 | 22 | Assert.True(left is IEquatable); 23 | 24 | var right = new Target 25 | { 26 | Property = "Test", 27 | }; 28 | 29 | Assert.Equal(left, right); 30 | Assert.Equal(left.GetHashCode(), right.GetHashCode()); 31 | } 32 | } -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | matrix: 2 | include: 3 | - os: linux 4 | language: csharp 5 | dist: xenial 6 | sudo: required 7 | mono: none 8 | dotnet: 3.1.302 9 | script: 10 | - dotnet build /p:Configuration=ReleaseNetCore /p:Platform="Any CPU" --framework netcoreapp3.1 11 | - dotnet test --no-build --configuration ReleaseNetCore --framework netcoreapp3.1 12 | - os: osx 13 | language: csharp 14 | sudo: required 15 | mono: none 16 | dotnet: 3.1.302 17 | script: 18 | - dotnet build /p:Configuration=ReleaseNetCore /p:Platform="Any CPU" --framework netcoreapp3.1 19 | - dotnet test --no-build --configuration ReleaseNetCore --framework netcoreapp3.1 -------------------------------------------------------------------------------- /ThrottleSample/ThrottleSample.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | net48 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /Samples/AnotarSplatSample/Logger.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Splat; 3 | 4 | namespace AnotarSplatSample; 5 | 6 | public class Logger : ILogger 7 | { 8 | public void Write(string message, LogLevel logLevel) => 9 | LogCaptureBuilder.LastMessage = message; 10 | 11 | public void Write(Exception exception, string message, LogLevel logLevel) => 12 | LogCaptureBuilder.LastMessage = message; 13 | 14 | public void Write(string message, Type type, LogLevel logLevel) => 15 | LogCaptureBuilder.LastMessage = message; 16 | 17 | public void Write(Exception exception, string message, Type type, LogLevel logLevel) => 18 | LogCaptureBuilder.LastMessage = message; 19 | 20 | public LogLevel Level { get; set; } 21 | } -------------------------------------------------------------------------------- /ToStringSample/Sample.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | using Xunit; 3 | 4 | public class ToStringSample 5 | { 6 | [Fact] 7 | public void Run() 8 | { 9 | var target = new Person 10 | { 11 | GivenNames = "John", 12 | FamilyName = "Smith" 13 | 14 | }; 15 | Debug.WriteLine(target.ToString()); 16 | Assert.Equal("{T: \"Person\", GivenNames: \"John\", FamilyName: \"Smith\"}", target.ToString()); 17 | } 18 | } 19 | 20 | [ToString] 21 | class Person 22 | { 23 | public string GivenNames { get; set; } 24 | public string FamilyName { get; set; } 25 | 26 | [IgnoreDuringToString] 27 | public string FullName => $"{GivenNames} {FamilyName}"; 28 | } -------------------------------------------------------------------------------- /Samples/ValidarSample/ValidationFactory.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using FluentValidation; 4 | 5 | namespace ValidarSample; 6 | 7 | public static class ValidationFactory 8 | { 9 | static Dictionary validators = new(); 10 | 11 | public static IValidator GetValidator(Type modelType) 12 | { 13 | if (!validators.TryGetValue(modelType.TypeHandle, out var validator)) 14 | { 15 | var type = modelType.Assembly 16 | .GetType($"{modelType.Namespace}.{modelType.Name}Validator", true); 17 | validator = (IValidator)Activator.CreateInstance(type); 18 | validators[modelType.TypeHandle] = validator; 19 | } 20 | 21 | return validator; 22 | } 23 | } -------------------------------------------------------------------------------- /LocalsInitSample/StackallocBenchmark.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics.CodeAnalysis; 2 | using System.Runtime.CompilerServices; 3 | using BenchmarkDotNet.Attributes; 4 | using LocalsInit; 5 | 6 | [InProcess] 7 | public unsafe class StackallocBenchmark 8 | { 9 | const int BufferSize = 4096; 10 | 11 | [Benchmark(Baseline = true)] 12 | [LocalsInit(true)] 13 | public void LocalsInitTrue() 14 | { 15 | var ptr = stackalloc byte[BufferSize]; 16 | Consume(ptr); 17 | } 18 | 19 | [Benchmark] 20 | [LocalsInit(false)] 21 | public void LocalsInitFalse() 22 | { 23 | var ptr = stackalloc byte[BufferSize]; 24 | Consume(ptr); 25 | } 26 | 27 | [SuppressMessage("ReSharper", "UnusedParameter.Local")] 28 | [MethodImpl(MethodImplOptions.NoInlining)] 29 | static void Consume(void* _) 30 | { 31 | } 32 | } -------------------------------------------------------------------------------- /Samples/AnotarCustomSample/Logger.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace AnotarCustomSample; 4 | 5 | public class Logger 6 | { 7 | [ThreadStatic] 8 | public static LogEntry LastMessage; 9 | 10 | public void Debug(string format, params object[] args) => 11 | LastMessage = new() 12 | { 13 | Format = format, 14 | Params = args, 15 | }; 16 | 17 | public void Debug(string format) => 18 | LastMessage = new() 19 | { 20 | Format = format, 21 | }; 22 | 23 | public void Debug(Exception exception, string format, params object[] args) => 24 | LastMessage = new() 25 | { 26 | Format = format, 27 | Params = args, 28 | Exception = exception 29 | }; 30 | 31 | public bool IsDebugEnabled => true; 32 | } -------------------------------------------------------------------------------- /Samples/FodyWeavers.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /Samples/ExtraConstraintsSample/DelegateConstraintSample.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.Security; 4 | using ExtraConstraints; 5 | using Xunit; 6 | // ReSharper disable UnusedParameter.Local 7 | 8 | public class DelegateConstraintSample 9 | { 10 | [Fact] 11 | public void InvalidDelegateConstraint() 12 | { 13 | var exception = Assert.Throws(() => MethodWithDelegateConstraint(10)); 14 | Assert.Equal("Method DelegateConstraintSample.MethodWithDelegateConstraint: type argument 'System.Int32' violates the constraint of type parameter 'T'.", exception.Message); 15 | } 16 | 17 | [Fact] 18 | public void ValidDelegateConstraint() => 19 | MethodWithDelegateConstraint(() => Debug.WriteLine("foo")); 20 | 21 | static void MethodWithDelegateConstraint<[DelegateConstraint(typeof(Action))] T>(T value) 22 | { 23 | } 24 | } -------------------------------------------------------------------------------- /Samples/ObsoleteSample.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using Xunit; 4 | 5 | public class ObsoleteSample 6 | { 7 | [Fact] 8 | public void Run() 9 | { 10 | //ObsoleteExAttribute will have been converted to an ObsoleteAttribute 11 | var obsoleteAttribute = (ObsoleteAttribute) typeof(TargetClass) 12 | .GetCustomAttributes(typeof(ObsoleteAttribute), false) 13 | .First(); 14 | 15 | var expectedMessage = "Decided this class was a bad idea. Use `NewTargetClass` instead. Will be treated as an error from version 3.0.0. Will be removed in version 4.0.0."; 16 | Assert.Equal(expectedMessage, obsoleteAttribute.Message); 17 | } 18 | 19 | [ObsoleteEx( 20 | Message = "Decided this class was a bad idea.", 21 | ReplacementTypeOrMember = "NewTargetClass", 22 | TreatAsErrorFromVersion = "3.0")] 23 | public class TargetClass; 24 | } -------------------------------------------------------------------------------- /Samples/PropertyChangingSample.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.ComponentModel; 3 | using Xunit; 4 | 5 | public class PropertyChangingSample 6 | { 7 | [Fact] 8 | public void Run() 9 | { 10 | var target = new Person(); 11 | var propertyNotifications = new List(); 12 | target.PropertyChanging += (_, args) => propertyNotifications.Add(args.PropertyName); 13 | target.FamilyName = "Smith"; 14 | Assert.Contains("FamilyName", propertyNotifications); 15 | Assert.Contains("FullName", propertyNotifications); 16 | } 17 | 18 | public class Person : INotifyPropertyChanging 19 | { 20 | public event PropertyChangingEventHandler PropertyChanging; 21 | 22 | public string GivenNames { get; set; } 23 | public string FamilyName { get; set; } 24 | 25 | public string FullName => $"{GivenNames} {FamilyName}"; 26 | } 27 | } -------------------------------------------------------------------------------- /Samples/ExtraConstraintsSample/EnumConstraintSample.cs: -------------------------------------------------------------------------------- 1 | using System.Security; 2 | using ExtraConstraints; 3 | using Xunit; 4 | // ReSharper disable UnusedParameter.Local 5 | 6 | public class EnumConstraintSample 7 | { 8 | [Fact] 9 | public void InvalidEnumConstraint() 10 | { 11 | var exception = Assert.Throws(() => MethodWithEnumConstraint(10)); 12 | Assert.Equal("Method EnumConstraintSample.MethodWithEnumConstraint: type argument 'System.Int32' violates the constraint of type parameter 'T'.", exception.Message); 13 | } 14 | 15 | [Fact] 16 | public void ValidEnumConstraint() => 17 | MethodWithEnumConstraint(MyEnum.Value); 18 | 19 | // ReSharper disable once MemberCanBeMadeStatic.Local 20 | void MethodWithEnumConstraint<[EnumConstraint(typeof(MyEnum))] T>(T value) 21 | { 22 | } 23 | 24 | public enum MyEnum 25 | { 26 | Value 27 | } 28 | } -------------------------------------------------------------------------------- /Samples/PropertyChangedSample.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.ComponentModel; 3 | using Xunit; 4 | 5 | public class PropertyChangedSample 6 | { 7 | [Fact] 8 | public void Run() 9 | { 10 | var target = new Person(); 11 | var propertyNotifications = new List(); 12 | target.PropertyChanged += (_, args) => propertyNotifications.Add(args.PropertyName); 13 | target.FamilyName = "Smith"; 14 | Assert.Contains("FamilyName", propertyNotifications); 15 | Assert.Contains("FullName", propertyNotifications); 16 | } 17 | 18 | public class Person : 19 | INotifyPropertyChanged 20 | { 21 | public event PropertyChangedEventHandler PropertyChanged; 22 | 23 | public string GivenNames { get; set; } 24 | public string FamilyName { get; set; } 25 | 26 | public string FullName => $"{GivenNames} {FamilyName}"; 27 | } 28 | } -------------------------------------------------------------------------------- /MethodDecoratorSample/Sample.cs: -------------------------------------------------------------------------------- 1 | using Xunit; 2 | 3 | [assembly: CollectionBehavior(DisableTestParallelization = true)] 4 | 5 | public class MethodDecoratorSample 6 | { 7 | [Fact] 8 | public void SimpleMethodSample() 9 | { 10 | InterceptionRecorder.Clear(); 11 | Target.MyMethod(); 12 | Assert.True(InterceptionRecorder.OnEntryCalled); 13 | Assert.True(InterceptionRecorder.OnExitCalled); 14 | Assert.False(InterceptionRecorder.OnExceptionCalled); 15 | } 16 | 17 | [Fact] 18 | public void ExceptionMethodSample() 19 | { 20 | InterceptionRecorder.Clear(); 21 | try 22 | { 23 | Target.MyExceptionMethod(); 24 | } 25 | catch 26 | { 27 | } 28 | Assert.True(InterceptionRecorder.OnEntryCalled); 29 | Assert.False(InterceptionRecorder.OnExitCalled); 30 | Assert.True(InterceptionRecorder.OnExceptionCalled); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Samples/JanitorSample.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Xunit; 3 | // ReSharper disable NotAccessedField.Local 4 | 5 | public class JanitorSample 6 | { 7 | [Fact] 8 | public void Run() 9 | { 10 | var disposable = new Disposable(); 11 | disposable.Dispose(); 12 | Assert.True(DisposeTracker.HasDisposedBeenCalled); 13 | } 14 | 15 | public class Disposable : IDisposable 16 | { 17 | DisposeTracker disposeTracker; 18 | 19 | public Disposable() => 20 | disposeTracker = new(); 21 | 22 | public void Dispose() 23 | { 24 | //must be empty 25 | } 26 | } 27 | 28 | /// 29 | /// A IDisposable class we will use to verify that fields in the sample have been disposed 30 | /// 31 | [Janitor.SkipWeaving] 32 | public class DisposeTracker : IDisposable 33 | { 34 | public static bool HasDisposedBeenCalled; 35 | 36 | public void Dispose() => 37 | HasDisposedBeenCalled = true; 38 | } 39 | } -------------------------------------------------------------------------------- /Samples/ValidarSample/ValidarSample.cs: -------------------------------------------------------------------------------- 1 | //using System.ComponentModel; 2 | //using Xunit; 3 | 4 | //TODO: 5 | //namespace ValidarSample 6 | //{ 7 | // public class ValidarSample 8 | // { 9 | // [Fact] 10 | // public void Run() 11 | // { 12 | // var person = new Person(); 13 | 14 | // // Validar had added and IDataErrorInfo implementation to Person 15 | // var personAsDataErrorInfo = (IDataErrorInfo)person; 16 | 17 | // //values will be invalid to start with 18 | // Assert.Equal("'Given Names' must not be empty.", personAsDataErrorInfo["GivenNames"]); 19 | // Assert.Equal("'Family Name' must not be empty.", personAsDataErrorInfo["FamilyName"]); 20 | 21 | // //Set to some valid values 22 | // person.FamilyName = "Smith"; 23 | // person.GivenNames = "John"; 24 | 25 | // Assert.Empty(personAsDataErrorInfo["GivenNames"]); 26 | // Assert.Empty(personAsDataErrorInfo["FamilyName"]); 27 | // } 28 | // } 29 | //} -------------------------------------------------------------------------------- /Samples/PublicizeSample.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel; 2 | using System.Linq; 3 | using System.Reflection; 4 | using Xunit; 5 | 6 | public class PublicizeSample 7 | { 8 | [Fact] 9 | public void Run() 10 | { 11 | var targetType = typeof (PublicizeTarget); 12 | 13 | Assert.True(targetType.IsPublic); 14 | var typeAttribute = GetEditorBrowsableAttribute(targetType); 15 | Assert.NotNull(typeAttribute); 16 | Assert.Equal(EditorBrowsableState.Advanced, typeAttribute.State); 17 | 18 | var methodInfo = targetType.GetMethod("Method"); 19 | Assert.True(methodInfo.IsPublic); 20 | var methodAttribute = GetEditorBrowsableAttribute(methodInfo); 21 | Assert.NotNull(methodAttribute); 22 | Assert.Equal(EditorBrowsableState.Advanced, methodAttribute.State); 23 | } 24 | 25 | static EditorBrowsableAttribute GetEditorBrowsableAttribute(MemberInfo memberInfo) => 26 | (EditorBrowsableAttribute)memberInfo.GetCustomAttributes(typeof(EditorBrowsableAttribute), false).First(); 27 | } -------------------------------------------------------------------------------- /Samples/AnotarCatelSample/CatelSample.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Anotar.Catel; 3 | using Catel.Logging; 4 | using Xunit; 5 | 6 | namespace AnotarCatelSample; 7 | 8 | public class CatelSample 9 | { 10 | [ThreadStatic] 11 | public static string LastMessage; 12 | 13 | static CatelSample() => 14 | LogManager.AddListener(new LogListener 15 | { 16 | Action = (s, _) => { LastMessage = s; } 17 | }); 18 | 19 | [Fact] 20 | public void RunException() 21 | { 22 | try 23 | { 24 | MyExceptionMethod(); 25 | } 26 | catch 27 | { 28 | } 29 | 30 | Assert.StartsWith("Exception occurred in 'Void MyExceptionMethod()'", LastMessage); 31 | } 32 | 33 | [LogToDebugOnException] 34 | static void MyExceptionMethod() => 35 | throw new("Foo"); 36 | 37 | [Fact] 38 | public void RunExplicit() 39 | { 40 | MyMethod(); 41 | 42 | Assert.Equal("Method: 'Void MyMethod()'. Line: ~46. TheMessage", LastMessage); 43 | } 44 | 45 | static void MyMethod() => 46 | LogTo.Debug("TheMessage"); 47 | } -------------------------------------------------------------------------------- /SubstituteSample/Sample.cs: -------------------------------------------------------------------------------- 1 | using System.Globalization; 2 | using System.Threading; 3 | 4 | using SubstituteSample.Properties; 5 | 6 | using Xunit; 7 | 8 | public class SubstituteSamples 9 | { 10 | [Fact] 11 | public void ResourceManager() 12 | { 13 | var target = Resources.String1; 14 | Assert.Equal("Override: String1 => English", target); 15 | 16 | Resources.Culture = CultureInfo.GetCultureInfo("de-DE"); 17 | 18 | target = Resources.String1; 19 | Assert.Equal("Override: String1 => Deutsch", target); 20 | } 21 | 22 | [Fact] 23 | public void ComponentResourceManager() 24 | { 25 | var target = new SampleForm(); 26 | 27 | Assert.Equal("Override: $this.Text => English", target.Text); 28 | Assert.Equal("Override: label1.Text => Label", target.label1.Text); 29 | 30 | Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("de-DE"); 31 | target = new SampleForm(); 32 | 33 | Assert.Equal("Override: $this.Text => Deutsch", target.Text); 34 | Assert.Equal("Override: label1.Text => TextField", target.label1.Text); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /license.txt: -------------------------------------------------------------------------------- 1 | The MIT License 2 | 3 | Copyright (c) 2012 Simon Cropp and contributors 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /ThrottleSample/FodyWeavers.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. 12 | 13 | 14 | 15 | 16 | A comma-separated list of error codes that can be safely ignored in assembly verification. 17 | 18 | 19 | 20 | 21 | 'false' to turn off automatic generation of the XML Schema file. 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /ToStringSample/FodyWeavers.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. 12 | 13 | 14 | 15 | 16 | A comma-separated list of error codes that can be safely ignored in assembly verification. 17 | 18 | 19 | 20 | 21 | 'false' to turn off automatic generation of the XML Schema file. 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /ReactiveUISample/FodyWeavers.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. 12 | 13 | 14 | 15 | 16 | A comma-separated list of error codes that can be safely ignored in assembly verification. 17 | 18 | 19 | 20 | 21 | 'false' to turn off automatic generation of the XML Schema file. 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /SubstituteSample/FodyWeavers.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. 12 | 13 | 14 | 15 | 16 | A comma-separated list of error codes that can be safely ignored in assembly verification. 17 | 18 | 19 | 20 | 21 | 'false' to turn off automatic generation of the XML Schema file. 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /MethodDecoratorSample/FodyWeavers.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. 12 | 13 | 14 | 15 | 16 | A comma-separated list of error codes that can be safely ignored in assembly verification. 17 | 18 | 19 | 20 | 21 | 'false' to turn off automatic generation of the XML Schema file. 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /WeakEventHandlerSample/FodyWeavers.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. 12 | 13 | 14 | 15 | 16 | A comma-separated list of error codes that can be safely ignored in assembly verification. 17 | 18 | 19 | 20 | 21 | 'false' to turn off automatic generation of the XML Schema file. 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /InSolutionWeaving/FodyWeavers.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. 13 | 14 | 15 | 16 | 17 | A comma-separated list of error codes that can be safely ignored in assembly verification. 18 | 19 | 20 | 21 | 22 | 'false' to turn off automatic generation of the XML Schema file. 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Samples/InfoOfSample/InfoOfSample.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.Reflection; 4 | using Xunit; 5 | // ReSharper disable UnusedVariable 6 | 7 | public class InfoOfSample 8 | { 9 | [Fact] 10 | public void Run() => 11 | Assert.NotNull(Info.OfMethod("Samples", "InternalClass", "Method")); 12 | 13 | [Fact] 14 | public void PerfWithInfoOf() 15 | { 16 | var stopwatch = Stopwatch.StartNew(); 17 | 18 | var methodInfo1 = Info.OfMethod("Samples", "InternalClass", "Method"); 19 | for (var i = 0; i < 10000; i++) 20 | { 21 | var methodInfo = Info.OfMethod("Samples", "InternalClass", "Method"); 22 | } 23 | stopwatch.Stop(); 24 | Debug.WriteLine(stopwatch.ElapsedMilliseconds); 25 | } 26 | 27 | [Fact] 28 | public void PerfWithReflection() 29 | { 30 | var stopwatch = Stopwatch.StartNew(); 31 | 32 | var type1 = Type.GetType("InternalClass, Samples")!; 33 | var methodInfo1 = type1.GetMethod("Method", BindingFlags.NonPublic | BindingFlags.Instance); 34 | for (var i = 0; i < 10000; i++) 35 | { 36 | var type = Type.GetType("InternalClass, Samples")!; 37 | var methodInfo = type.GetMethod("Method",BindingFlags.NonPublic| BindingFlags.Instance); 38 | } 39 | stopwatch.Stop(); 40 | Debug.WriteLine(stopwatch.ElapsedMilliseconds); 41 | } 42 | } -------------------------------------------------------------------------------- /ThrottleSample/Sample.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading; 3 | using System.Windows.Threading; 4 | using Throttle; 5 | using Xunit; 6 | 7 | public class ThrottleSample 8 | { 9 | int throttledCalls; 10 | 11 | [Fact] 12 | public void Run() 13 | { 14 | var dispatcher = Dispatcher.CurrentDispatcher; 15 | 16 | dispatcher.BeginInvoke(() => 17 | { 18 | ThrottledMethod(); 19 | Delay(5); 20 | ThrottledMethod(); 21 | Delay(5); 22 | ThrottledMethod(); 23 | Delay(5); 24 | ThrottledMethod(); 25 | Delay(5); 26 | ThrottledMethod(); 27 | Delay(5); 28 | Assert.Equal(0, throttledCalls); 29 | Delay(200); 30 | Assert.Equal(1, throttledCalls); 31 | 32 | dispatcher.BeginInvokeShutdown(DispatcherPriority.ApplicationIdle); 33 | }); 34 | 35 | Dispatcher.Run(); 36 | } 37 | 38 | static void Delay(int timeSpan) 39 | { 40 | var frame = new DispatcherFrame(); 41 | var timer = new DispatcherTimer(TimeSpan.FromMilliseconds(timeSpan), DispatcherPriority.Normal, (_, _) => frame.Continue = false, Dispatcher.CurrentDispatcher); 42 | timer.Start(); 43 | Dispatcher.PushFrame(frame); 44 | } 45 | 46 | [Throttled(typeof(TomsToolbox.Wpf.Throttle), 100)] 47 | void ThrottledMethod() => 48 | Interlocked.Increment(ref throttledCalls); 49 | } 50 | 51 | -------------------------------------------------------------------------------- /Samples/ValidarSample/ValidationTemplate.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel; 3 | using System.Linq; 4 | using FluentValidation; 5 | using FluentValidation.Results; 6 | 7 | namespace ValidarSample; 8 | 9 | public class ValidationTemplate : 10 | IDataErrorInfo where T: INotifyPropertyChanged 11 | { 12 | public ValidationTemplate(T target) 13 | { 14 | validator = ValidationFactory.GetValidator(target.GetType()); 15 | context = new(target); 16 | result = validator.Validate(context); 17 | target.PropertyChanged += Validate; 18 | } 19 | 20 | void Validate(object sender, PropertyChangedEventArgs e) 21 | { 22 | if (validator != null) 23 | { 24 | result = validator.Validate(context); 25 | } 26 | } 27 | 28 | IValidator validator; 29 | ValidationResult result; 30 | ValidationContext context; 31 | 32 | public string Error 33 | { 34 | get 35 | { 36 | var strings = result.Errors 37 | .Select(_ => _.ErrorMessage); 38 | return string.Join(Environment.NewLine, strings); 39 | } 40 | } 41 | 42 | public string this[string propertyName] 43 | { 44 | get 45 | { 46 | var strings = result.Errors 47 | .Where(_ => _.PropertyName == propertyName) 48 | .Select(_ => _.ErrorMessage); 49 | return string.Join(Environment.NewLine, strings); 50 | } 51 | } 52 | } -------------------------------------------------------------------------------- /SubstituteSample/Substitutes.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel; 3 | using System.Globalization; 4 | using System.Reflection; 5 | using System.Resources; 6 | 7 | using Substitute; 8 | 9 | [assembly: Substitute(typeof(ComponentResourceManager), typeof(MyComponentResourceManager))] 10 | [assembly: Substitute(typeof(ResourceManager), typeof(MyResourceManager))] 11 | 12 | public class MyComponentResourceManager : ComponentResourceManager 13 | { 14 | public MyComponentResourceManager(Type t) 15 | : base(t) 16 | { 17 | } 18 | 19 | // a substitute must implement all (even implicit) used methods of the substituted type. 20 | public new void ApplyResources(object value, string objectName) 21 | { 22 | base.ApplyResources(value, objectName); 23 | } 24 | 25 | public override void ApplyResources(object value, string objectName, CultureInfo culture) 26 | { 27 | ((dynamic)value).Text = GetString($"{objectName}.Text", culture); 28 | } 29 | 30 | public override string GetString(string name, CultureInfo culture) 31 | { 32 | return $"Override: {name} => {base.GetString(name, culture)}"; 33 | } 34 | } 35 | 36 | public class MyResourceManager : ResourceManager 37 | { 38 | public MyResourceManager(string s, Assembly assembly) 39 | : base(s, assembly) 40 | { 41 | 42 | } 43 | 44 | public override string GetString(string name, CultureInfo culture) 45 | { 46 | return $"Override: {name} => {base.GetString(name, culture)}"; 47 | } 48 | } -------------------------------------------------------------------------------- /SubstituteSample/SubstituteSample.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | net48 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | True 15 | True 16 | Resources.resx 17 | 18 | 19 | Resources.resx 20 | 21 | 22 | ResXFileCodeGenerator 23 | Resources.Designer.cs 24 | 25 | 26 | SampleForm.cs 27 | 28 | 29 | SampleForm.cs 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ################# 2 | ## Visual Studio 3 | ################# 4 | 5 | ## Ignore Visual Studio temporary files, build results, and 6 | ## files generated by popular Visual Studio add-ons. 7 | 8 | # User-specific files 9 | *.suo 10 | *.user 11 | *.sln.docstates 12 | *.pidb 13 | *.ncrunchsolution 14 | *.ncrunchproject 15 | 16 | .idea 17 | *.dll 18 | *.pdb 19 | 20 | # Build results 21 | [Dd]ebug/ 22 | [Rr]elease/ 23 | *_i.c 24 | *_p.c 25 | *.ilk 26 | *.meta 27 | *.obj 28 | *.pch 29 | *.pgc 30 | *.pgd 31 | *.rsp 32 | *.sbr 33 | *.tlb 34 | *.tli 35 | *.tlh 36 | *.tmp 37 | *.vspscc 38 | .builds 39 | *.dotCover 40 | *.dot 41 | 42 | ## If you have NuGet Package Restore enabled, uncomment this 43 | packages/ 44 | ForSample/ 45 | 46 | *test-results* 47 | 48 | # Visual Studio profiler 49 | *.psess 50 | *.vsp 51 | 52 | *.userprefs 53 | 54 | # ReSharper is a .NET coding add-in 55 | _ReSharper* 56 | 57 | # Others 58 | [Bb]in 59 | [Oo]bj 60 | sql 61 | TestResults 62 | *.Cache 63 | ClientBin 64 | stylecop.* 65 | ~$* 66 | *.dbmdl 67 | Generated_Code #added for RIA/Silverlight projects 68 | 69 | # Backup & report files from converting an old project file to a newer 70 | # Visual Studio version. Backup files are not needed, because we have git ;-) 71 | _UpgradeReport_Files/ 72 | Backup*/ 73 | UpgradeLog*.XML 74 | 75 | 76 | ############ 77 | ## Windows 78 | ############ 79 | 80 | # Windows image file caches 81 | Thumbs.db 82 | 83 | # Folder config file 84 | Desktop.ini 85 | 86 | /Tools/BixMixersMixinImplementations.dll 87 | 88 | .vs 89 | /JetBrainsAnnotationsSample/JetBrainsAnnotationsSample.ExternalAnnotations.xml 90 | -------------------------------------------------------------------------------- /LocalsInitSample/FodyWeavers.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | Defines the default value for the localsinit flag. 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. 20 | 21 | 22 | 23 | 24 | A comma-separated list of error codes that can be safely ignored in assembly verification. 25 | 26 | 27 | 28 | 29 | 'false' to turn off automatic generation of the XML Schema file. 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /SubstituteSample/SampleForm.Designer.cs: -------------------------------------------------------------------------------- 1 | partial class SampleForm 2 | { 3 | /// 4 | /// Required designer variable. 5 | /// 6 | private System.ComponentModel.IContainer components = null; 7 | 8 | /// 9 | /// Clean up any resources being used. 10 | /// 11 | /// true if managed resources should be disposed; otherwise, false. 12 | protected override void Dispose(bool disposing) 13 | { 14 | if (disposing && (components != null)) 15 | { 16 | components.Dispose(); 17 | } 18 | base.Dispose(disposing); 19 | } 20 | 21 | #region Windows Form Designer generated code 22 | 23 | /// 24 | /// Required method for Designer support - do not modify 25 | /// the contents of this method with the code editor. 26 | /// 27 | private void InitializeComponent() 28 | { 29 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(SampleForm)); 30 | this.label1 = new System.Windows.Forms.Label(); 31 | this.SuspendLayout(); 32 | // 33 | // label1 34 | // 35 | resources.ApplyResources(this.label1, "label1"); 36 | this.label1.Name = "label1"; 37 | // 38 | // SampleForm 39 | // 40 | resources.ApplyResources(this, "$this"); 41 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 42 | this.Controls.Add(this.label1); 43 | this.Name = "SampleForm"; 44 | this.ResumeLayout(false); 45 | this.PerformLayout(); 46 | 47 | } 48 | 49 | #endregion 50 | 51 | public System.Windows.Forms.Label label1; 52 | } -------------------------------------------------------------------------------- /WeakEventHandlerSample/Test.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace WeakEventHandlerSample; 4 | 5 | using Xunit; 6 | 7 | public class Test 8 | { 9 | [Fact] 10 | public void ExplicitUnsubscribe() 11 | { 12 | var lastEvent = (string)null; 13 | 14 | var source = new EventSource(); 15 | 16 | var target = new EventSink(source, e => lastEvent = e); 17 | 18 | source.OnEvent(); 19 | 20 | Assert.Null(lastEvent); 21 | 22 | target.Subscribe(); 23 | 24 | Assert.True(source.HasEventHandlersAttached); 25 | 26 | source.OnEvent(); 27 | 28 | Assert.Equal("Event", lastEvent); 29 | 30 | lastEvent = null; 31 | 32 | target.Unsubscribe(); 33 | 34 | source.OnEvent(); 35 | 36 | Assert.False(source.HasEventHandlersAttached); 37 | Assert.Null(lastEvent); 38 | } 39 | 40 | [Fact] 41 | public void TargetIsGarbageCollected() 42 | { 43 | var lastEvent = (string)null; 44 | 45 | var source = new EventSource(); 46 | 47 | void Inner() 48 | { 49 | var target = new EventSink(source, e => lastEvent = e); 50 | 51 | source.OnEvent(); 52 | 53 | Assert.Null(lastEvent); 54 | 55 | target.Subscribe(); 56 | 57 | Assert.True(source.HasEventHandlersAttached); 58 | 59 | source.OnEvent(); 60 | 61 | Assert.Equal("Event", lastEvent); 62 | 63 | lastEvent = null; 64 | } 65 | 66 | Inner(); 67 | 68 | GCCollect(); 69 | 70 | source.OnEvent(); 71 | 72 | Assert.False(source.HasEventHandlersAttached); 73 | Assert.Null(lastEvent); 74 | } 75 | 76 | static void GCCollect() 77 | { 78 | GC.Collect(); 79 | GC.WaitForPendingFinalizers(); 80 | GC.WaitForFullGCApproach(); 81 | } 82 | } -------------------------------------------------------------------------------- /Samples/Samples.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | net8.0 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /SubstituteSample/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace SubstituteSample.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// Returns the cached ResourceManager instance used by this class. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SubstituteSample.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Overrides the current thread's CurrentUICulture property for all 51 | /// resource lookups using this strongly typed resource class. 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | 63 | /// 64 | /// Looks up a localized string similar to English. 65 | /// 66 | internal static string String1 { 67 | get { 68 | return ResourceManager.GetString("String1", resourceCulture); 69 | } 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /NullGuardSample/FodyWeavers.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | Used to control whether asserts are added into debug builds or not. 12 | 13 | 14 | 15 | 16 | The operation mode of NullGuard. 17 | 18 | 19 | 20 | 21 | 22 | Automatically detect the mode by the usage of JetBrains.Annotations. 23 | 24 | 25 | 26 | 27 | In implicit mode everything is assumed to be not-null, unless attributed with [AllowNull]. 28 | 29 | 30 | 31 | 32 | In explicit mode everything is assumed to be nullable, unless attributed with [NotNull]. 33 | 34 | 35 | 36 | 37 | Use C# 8 nullable reference type annotations. 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | A regular expression to specify the names of a classes to exclude from NullGuard. 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. 54 | 55 | 56 | 57 | 58 | A comma-separated list of error codes that can be safely ignored in assembly verification. 59 | 60 | 61 | 62 | 63 | 'false' to turn off automatic generation of the XML Schema file. 64 | 65 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /CatelSample/FodyWeavers.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | Weave all regular properties on classes that inherit (directly or indirectly) from `Catel.Data.ModelBase` into Catel properties. The default value is true. 13 | 14 | 15 | 16 | 17 | 18 | 19 | Weave all Catel properties decorated with both the `Catel.MVVM.ModelAttribute` and `Fody.ExposeAttribute` attributes as automatic mappings. The default value is true. 20 | 21 | 22 | 23 | 24 | 25 | 26 | Automatically raise change notifications for calculated properties (e.g. `FullName => FirstName + " " + LastName`). The default value is true. 27 | 28 | 29 | 30 | 31 | 32 | 33 | Weave all Argument check attributes into actual argument checks. The default value is true. 34 | 35 | 36 | 37 | 38 | 39 | 40 | Weave all calls to `LogManager.GetCurrentClassLogger()` into `LogManager.GetLogger(typeof(classname))`. The default value is true. 41 | 42 | 43 | 44 | 45 | 46 | 47 | Generate xml schemas for all classes that inherit (directly or indirectly) from `Catel.Data.ModelBase`. The default value is false. 48 | 49 | 50 | 51 | 52 | 53 | 54 | The accessibility for generated property data. The default value is `Public`. Use either `Public`, `Internal` or `Private`. 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. 64 | 65 | 66 | 67 | 68 | A comma-separated list of error codes that can be safely ignored in assembly verification. 69 | 70 | 71 | 72 | 73 | 'false' to turn off automatic generation of the XML Schema file. 74 | 75 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /InlineILSample/FodyWeavers.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | Defines if sequence points should be generated for each emitted IL instruction. Default value: Debug 12 | 13 | 14 | 15 | 16 | 17 | Insert sequence points in Debug builds only (this is the default). 18 | 19 | 20 | 21 | 22 | Insert sequence points in Release builds only. 23 | 24 | 25 | 26 | 27 | Always insert sequence points. 28 | 29 | 30 | 31 | 32 | Never insert sequence points. 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | Defines how warnings should be handled. Default value: Warnings 41 | 42 | 43 | 44 | 45 | 46 | Emit build warnings (this is the default). 47 | 48 | 49 | 50 | 51 | Do not emit warnings. 52 | 53 | 54 | 55 | 56 | Treat warnings as errors. 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. 68 | 69 | 70 | 71 | 72 | A comma-separated list of error codes that can be safely ignored in assembly verification. 73 | 74 | 75 | 76 | 77 | 'false' to turn off automatic generation of the XML Schema file. 78 | 79 | 80 | 81 | 82 | -------------------------------------------------------------------------------- /SubstituteSample/Properties/Resources.de.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | Deutsch 122 | 123 | -------------------------------------------------------------------------------- /SubstituteSample/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | English 122 | 123 | -------------------------------------------------------------------------------- /SubstituteSample/SampleForm.de.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | Deutsch 122 | 123 | 124 | TextField 125 | 126 | -------------------------------------------------------------------------------- /Samples/FodyWeavers.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | Used to control if the On_PropertyName_Changed feature is enabled. 18 | 19 | 20 | 21 | 22 | Used to control if the Dependent properties feature is enabled. 23 | 24 | 25 | 26 | 27 | Used to control if the IsChanged property feature is enabled. 28 | 29 | 30 | 31 | 32 | Used to change the name of the method that fires the notify event. This is a string that accepts multiple values in a comma separated form. 33 | 34 | 35 | 36 | 37 | Used to control if equality checks should be inserted. If false, equality checking will be disabled for the project. 38 | 39 | 40 | 41 | 42 | Used to control if equality checks should use the Equals method resolved from the base class. 43 | 44 | 45 | 46 | 47 | Used to control if equality checks should use the static Equals method resolved from the base class. 48 | 49 | 50 | 51 | 52 | Used to turn off build warnings from this weaver. 53 | 54 | 55 | 56 | 57 | Used to turn off build warnings about mismatched On_PropertyName_Changed methods. 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | Namespace to use for the injected type 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. 97 | 98 | 99 | 100 | 101 | A comma-separated list of error codes that can be safely ignored in assembly verification. 102 | 103 | 104 | 105 | 106 | 'false' to turn off automatic generation of the XML Schema file. 107 | 108 | 109 | 110 | 111 | -------------------------------------------------------------------------------- /SubstituteSample/SampleForm.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 122 | True 123 | 124 | 125 | 126 | 12, 9 127 | 128 | 129 | 33, 13 130 | 131 | 132 | 0 133 | 134 | 135 | Label 136 | 137 | 138 | label1 139 | 140 | 141 | System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 142 | 143 | 144 | $this 145 | 146 | 147 | 0 148 | 149 | 150 | True 151 | 152 | 153 | 6, 13 154 | 155 | 156 | 800, 450 157 | 158 | 159 | English 160 | 161 | 162 | SampleForm 163 | 164 | 165 | System.Windows.Forms.Form, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 166 | 167 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | # EditorConfig: http://EditorConfig.org 3 | 4 | # top-most EditorConfig file 5 | 6 | [*] 7 | indent_style = space 8 | 9 | 10 | [*.cs] 11 | indent_size = 4 12 | charset = utf-8 13 | 14 | 15 | # Microsoft .NET properties 16 | trim_trailing_whitespace = true 17 | csharp_preferred_modifier_order = public, private, protected, internal, new, static, abstract, virtual, sealed, readonly, override, extern, unsafe, volatile, async:suggestion 18 | resharper_namespace_body = file_scoped 19 | dotnet_naming_rule.private_constants_rule.severity = warning 20 | dotnet_naming_rule.private_constants_rule.style = upper_camel_case_style 21 | dotnet_naming_rule.private_constants_rule.symbols = private_constants_symbols 22 | dotnet_naming_rule.private_instance_fields_rule.severity = warning 23 | dotnet_naming_rule.private_instance_fields_rule.style = lower_camel_case_style 24 | dotnet_naming_rule.private_instance_fields_rule.symbols = private_instance_fields_symbols 25 | dotnet_naming_rule.private_static_fields_rule.severity = warning 26 | dotnet_naming_rule.private_static_fields_rule.style = lower_camel_case_style 27 | dotnet_naming_rule.private_static_fields_rule.symbols = private_static_fields_symbols 28 | dotnet_naming_rule.private_static_readonly_rule.severity = warning 29 | dotnet_naming_rule.private_static_readonly_rule.style = upper_camel_case_style 30 | dotnet_naming_rule.private_static_readonly_rule.symbols = private_static_readonly_symbols 31 | dotnet_naming_style.lower_camel_case_style.capitalization = camel_case 32 | dotnet_naming_style.upper_camel_case_style.capitalization = pascal_case 33 | dotnet_naming_symbols.private_constants_symbols.applicable_accessibilities = private 34 | dotnet_naming_symbols.private_constants_symbols.applicable_kinds = field 35 | dotnet_naming_symbols.private_constants_symbols.required_modifiers = const 36 | dotnet_naming_symbols.private_instance_fields_symbols.applicable_accessibilities = private 37 | dotnet_naming_symbols.private_instance_fields_symbols.applicable_kinds = field 38 | dotnet_naming_symbols.private_static_fields_symbols.applicable_accessibilities = private 39 | dotnet_naming_symbols.private_static_fields_symbols.applicable_kinds = field 40 | dotnet_naming_symbols.private_static_fields_symbols.required_modifiers = static 41 | dotnet_naming_symbols.private_static_readonly_symbols.applicable_accessibilities = private 42 | dotnet_naming_symbols.private_static_readonly_symbols.applicable_kinds = field 43 | dotnet_naming_symbols.private_static_readonly_symbols.required_modifiers = static, readonly 44 | dotnet_style_parentheses_in_arithmetic_binary_operators = never_if_unnecessary:none 45 | dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:none 46 | dotnet_style_parentheses_in_relational_binary_operators = never_if_unnecessary:none 47 | 48 | # ReSharper properties 49 | resharper_object_creation_when_type_not_evident = target_typed 50 | 51 | # ReSharper inspection severities 52 | resharper_arrange_object_creation_when_type_evident_highlighting = error 53 | resharper_arrange_object_creation_when_type_not_evident_highlighting = error 54 | resharper_arrange_redundant_parentheses_highlighting = error 55 | resharper_arrange_static_member_qualifier_highlighting = error 56 | resharper_arrange_this_qualifier_highlighting = hint 57 | resharper_arrange_type_member_modifiers_highlighting = none 58 | resharper_built_in_type_reference_style_for_member_access_highlighting = hint 59 | resharper_built_in_type_reference_style_highlighting = hint 60 | resharper_check_namespace_highlighting = none 61 | resharper_convert_to_using_declaration_highlighting = error 62 | resharper_css_not_resolved_highlighting = warning 63 | resharper_field_can_be_made_read_only_local_highlighting = none 64 | resharper_merge_into_logical_pattern_highlighting = warning 65 | resharper_merge_into_pattern_highlighting = error 66 | resharper_method_has_async_overload_highlighting = warning 67 | resharper_partial_type_with_single_part_highlighting = error 68 | resharper_redundant_base_qualifier_highlighting = warning 69 | resharper_redundant_cast_highlighting = error 70 | resharper_redundant_empty_object_creation_argument_list_highlighting = error 71 | resharper_redundant_empty_object_or_collection_initializer_highlighting = error 72 | resharper_redundant_name_qualifier_highlighting = error 73 | resharper_redundant_suppress_nullable_warning_expression_highlighting = error 74 | resharper_redundant_using_directive_highlighting = error 75 | resharper_redundant_verbatim_string_prefix_highlighting = error 76 | resharper_replace_substring_with_range_indexer_highlighting = warning 77 | resharper_suggest_var_or_type_built_in_types_highlighting = error 78 | resharper_suggest_var_or_type_elsewhere_highlighting = error 79 | resharper_suggest_var_or_type_simple_types_highlighting = error 80 | resharper_unnecessary_whitespace_highlighting = error 81 | resharper_use_await_using_highlighting = warning 82 | resharper_use_deconstruction_highlighting = warning 83 | 84 | # Sort using and Import directives with System.* appearing first 85 | dotnet_sort_system_directives_first = true 86 | 87 | # Avoid "this." and "Me." if not necessary 88 | dotnet_style_qualification_for_field = false:error 89 | dotnet_style_qualification_for_property = false:error 90 | dotnet_style_qualification_for_method = false:error 91 | dotnet_style_qualification_for_event = false:error 92 | 93 | # Use language keywords instead of framework type names for type references 94 | dotnet_style_predefined_type_for_locals_parameters_members = true:error 95 | dotnet_style_predefined_type_for_member_access = true:error 96 | 97 | # Suggest more modern language features when available 98 | dotnet_style_object_initializer = true:suggestion 99 | dotnet_style_collection_initializer = true:suggestion 100 | dotnet_style_coalesce_expression = false:suggestion 101 | dotnet_style_null_propagation = true:suggestion 102 | dotnet_style_explicit_tuple_names = true:suggestion 103 | 104 | # Prefer "var" everywhere 105 | csharp_style_var_for_built_in_types = true:error 106 | csharp_style_var_when_type_is_apparent = true:error 107 | csharp_style_var_elsewhere = true:error 108 | 109 | # Prefer method-like constructs to have a block body 110 | csharp_style_expression_bodied_methods = true:error 111 | csharp_style_expression_bodied_local_functions = true:error 112 | csharp_style_expression_bodied_constructors = true:error 113 | csharp_style_expression_bodied_operators = true:error 114 | resharper_place_expr_method_on_single_line = false 115 | 116 | # Prefer property-like constructs to have an expression-body 117 | csharp_style_expression_bodied_properties = true:error 118 | csharp_style_expression_bodied_indexers = true:error 119 | csharp_style_expression_bodied_accessors = true:error 120 | 121 | # Suggest more modern language features when available 122 | csharp_style_pattern_matching_over_is_with_cast_check = true:error 123 | csharp_style_pattern_matching_over_as_with_null_check = true:error 124 | csharp_style_inlined_variable_declaration = true:suggestion 125 | csharp_style_throw_expression = true:suggestion 126 | csharp_style_conditional_delegate_call = true:suggestion 127 | 128 | # Newline settings 129 | #csharp_new_line_before_open_brace = all:error 130 | resharper_max_array_initializer_elements_on_line = 1 131 | csharp_new_line_before_else = true 132 | csharp_new_line_before_catch = true 133 | csharp_new_line_before_finally = true 134 | csharp_new_line_before_members_in_object_initializers = true 135 | csharp_new_line_before_members_in_anonymous_types = true 136 | resharper_wrap_before_first_type_parameter_constraint = true 137 | resharper_wrap_extends_list_style = chop_always 138 | resharper_wrap_after_dot_in_method_calls = false 139 | resharper_wrap_before_binary_pattern_op = false 140 | resharper_wrap_object_and_collection_initializer_style = chop_always 141 | resharper_place_simple_initializer_on_single_line = false 142 | 143 | dotnet_style_require_accessibility_modifiers = never:error 144 | resharper_place_type_constraints_on_same_line = false 145 | resharper_blank_lines_inside_namespace = 0 146 | resharper_blank_lines_after_file_scoped_namespace_directive = 1 147 | resharper_blank_lines_inside_type = 0 148 | 149 | insert_final_newline = false 150 | resharper_place_attribute_on_same_line = false 151 | resharper_space_around_lambda_arrow = true 152 | resharper_place_constructor_initializer_on_same_line = false 153 | 154 | #braces https://www.jetbrains.com/help/resharper/EditorConfig_CSHARP_CSharpCodeStylePageImplSchema.html#Braces 155 | resharper_braces_for_ifelse = required 156 | resharper_braces_for_foreach = required 157 | resharper_braces_for_while = required 158 | resharper_braces_for_dowhile = required 159 | resharper_braces_for_lock = required 160 | resharper_braces_for_fixed = required 161 | resharper_braces_for_for = required 162 | 163 | # Xml files 164 | [*.{xml,config,nuspec,resx,vsixmanifest,csproj,targets,props}] 165 | indent_size = 2 166 | # https://www.jetbrains.com/help/resharper/EditorConfig_XML_XmlCodeStylePageSchema.html#resharper_xml_blank_line_after_pi 167 | resharper_blank_line_after_pi = false 168 | resharper_space_before_self_closing = true 169 | 170 | [*.json] 171 | indent_size = 2 -------------------------------------------------------------------------------- /CosturaSample/FodyWeavers.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with line breaks 13 | 14 | 15 | 16 | 17 | A list of assembly names to include from the default action of "embed all Copy Local references", delimited with line breaks. 18 | 19 | 20 | 21 | 22 | A list of runtime assembly names to exclude from the default action of "embed all Copy Local references", delimited with line breaks 23 | 24 | 25 | 26 | 27 | A list of runtime assembly names to include from the default action of "embed all Copy Local references", delimited with line breaks. 28 | 29 | 30 | 31 | 32 | A list of unmanaged 32 bit assembly names to include, delimited with line breaks. 33 | 34 | 35 | 36 | 37 | A list of unmanaged 64 bit assembly names to include, delimited with line breaks. 38 | 39 | 40 | 41 | 42 | The order of preloaded assemblies, delimited with line breaks. 43 | 44 | 45 | 46 | 47 | 48 | This will copy embedded files to disk before loading them into memory. This is helpful for some scenarios that expected an assembly to be loaded from a physical file. 49 | 50 | 51 | 52 | 53 | Controls if .pdbs for reference assemblies are also embedded. 54 | 55 | 56 | 57 | 58 | Controls if runtime assemblies are also embedded. 59 | 60 | 61 | 62 | 63 | Controls whether the runtime assemblies are embedded with their full path or only with their assembly name. 64 | 65 | 66 | 67 | 68 | Embedded assemblies are compressed by default, and uncompressed when they are loaded. You can turn compression off with this option. 69 | 70 | 71 | 72 | 73 | As part of Costura, embedded assemblies are no longer included as part of the build. This cleanup can be turned off. 74 | 75 | 76 | 77 | 78 | Costura by default will load as part of the module initialization. This flag disables that behavior. Make sure you call CosturaUtility.Initialize() somewhere in your code. 79 | 80 | 81 | 82 | 83 | Costura will by default use assemblies with a name like 'resources.dll' as a satellite resource and prepend the output path. This flag disables that behavior. 84 | 85 | 86 | 87 | 88 | A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with | 89 | 90 | 91 | 92 | 93 | A list of assembly names to include from the default action of "embed all Copy Local references", delimited with |. 94 | 95 | 96 | 97 | 98 | A list of runtime assembly names to exclude from the default action of "embed all Copy Local references", delimited with | 99 | 100 | 101 | 102 | 103 | A list of runtime assembly names to include from the default action of "embed all Copy Local references", delimited with |. 104 | 105 | 106 | 107 | 108 | A list of unmanaged 32 bit assembly names to include, delimited with |. 109 | 110 | 111 | 112 | 113 | A list of unmanaged 64 bit assembly names to include, delimited with |. 114 | 115 | 116 | 117 | 118 | The order of preloaded assemblies, delimited with |. 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. 127 | 128 | 129 | 130 | 131 | A comma-separated list of error codes that can be safely ignored in assembly verification. 132 | 133 | 134 | 135 | 136 | 'false' to turn off automatic generation of the XML Schema file. 137 | 138 | 139 | 140 | 141 | -------------------------------------------------------------------------------- /Samples/AnotarCommonLoggingSample/ActionAppender.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Common.Logging; 3 | 4 | namespace AnotarCommonLoggingSample; 5 | 6 | public class ActionAdapter : ILoggerFactoryAdapter 7 | { 8 | public ILog GetLogger(Type type) => 9 | throw new NotImplementedException(); 10 | 11 | public ILog GetLogger(string name) => 12 | new ActionLog(); 13 | } 14 | 15 | public class ActionLog : ILog 16 | { 17 | public void Trace(object message) => 18 | throw new NotImplementedException(); 19 | 20 | public void Trace(object message, Exception exception) => 21 | throw new NotImplementedException(); 22 | 23 | public void TraceFormat(string format, params object[] args) => 24 | throw new NotImplementedException(); 25 | 26 | public void TraceFormat(string format, Exception exception, params object[] args) => 27 | throw new NotImplementedException(); 28 | 29 | public void TraceFormat(IFormatProvider formatProvider, string format, params object[] args) => 30 | throw new NotImplementedException(); 31 | 32 | public void TraceFormat(IFormatProvider formatProvider, string format, Exception exception, params object[] args) => 33 | throw new NotImplementedException(); 34 | 35 | public void Trace(Action formatMessageCallback) => 36 | throw new NotImplementedException(); 37 | 38 | public void Trace(Action formatMessageCallback, Exception exception) => 39 | throw new NotImplementedException(); 40 | 41 | public void Trace(IFormatProvider formatProvider, Action formatMessageCallback) => 42 | throw new NotImplementedException(); 43 | 44 | public void Trace(IFormatProvider formatProvider, Action formatMessageCallback, Exception exception) => 45 | throw new NotImplementedException(); 46 | 47 | public void Debug(object message) => 48 | LogCaptureBuilder.LastMessage = message.ToString(); 49 | 50 | public void Debug(object message, Exception exception) => 51 | throw new NotImplementedException(); 52 | 53 | public void DebugFormat(string format, params object[] args) => 54 | LogCaptureBuilder.LastMessage = format; 55 | 56 | public void DebugFormat(string format, Exception exception, params object[] args) => 57 | LogCaptureBuilder.LastMessage = format; 58 | 59 | public void DebugFormat(IFormatProvider formatProvider, string format, params object[] args) => 60 | throw new NotImplementedException(); 61 | 62 | public void DebugFormat(IFormatProvider formatProvider, string format, Exception exception, params object[] args) => 63 | LogCaptureBuilder.LastMessage = format; 64 | 65 | public void Debug(Action formatMessageCallback) => 66 | throw new NotImplementedException(); 67 | 68 | public void Debug(Action formatMessageCallback, Exception exception) => 69 | throw new NotImplementedException(); 70 | 71 | public void Debug(IFormatProvider formatProvider, Action formatMessageCallback) => 72 | throw new NotImplementedException(); 73 | 74 | public void Debug(IFormatProvider formatProvider, Action formatMessageCallback, Exception exception) => 75 | throw new NotImplementedException(); 76 | 77 | public void Info(object message) => 78 | throw new NotImplementedException(); 79 | 80 | public void Info(object message, Exception exception) => 81 | throw new NotImplementedException(); 82 | 83 | public void InfoFormat(string format, params object[] args) => 84 | throw new NotImplementedException(); 85 | 86 | public void InfoFormat(string format, Exception exception, params object[] args) => 87 | throw new NotImplementedException(); 88 | 89 | public void InfoFormat(IFormatProvider formatProvider, string format, params object[] args) => 90 | throw new NotImplementedException(); 91 | 92 | public void InfoFormat(IFormatProvider formatProvider, string format, Exception exception, params object[] args) => 93 | throw new NotImplementedException(); 94 | 95 | public void Info(Action formatMessageCallback) => 96 | throw new NotImplementedException(); 97 | 98 | public void Info(Action formatMessageCallback, Exception exception) => 99 | throw new NotImplementedException(); 100 | 101 | public void Info(IFormatProvider formatProvider, Action formatMessageCallback) => 102 | throw new NotImplementedException(); 103 | 104 | public void Info(IFormatProvider formatProvider, Action formatMessageCallback, Exception exception) => 105 | throw new NotImplementedException(); 106 | 107 | public void Warn(object message) => 108 | throw new NotImplementedException(); 109 | 110 | public void Warn(object message, Exception exception) => 111 | throw new NotImplementedException(); 112 | 113 | public void WarnFormat(string format, params object[] args) => 114 | throw new NotImplementedException(); 115 | 116 | public void WarnFormat(string format, Exception exception, params object[] args) => 117 | throw new NotImplementedException(); 118 | 119 | public void WarnFormat(IFormatProvider formatProvider, string format, params object[] args) => 120 | throw new NotImplementedException(); 121 | 122 | public void WarnFormat(IFormatProvider formatProvider, string format, Exception exception, params object[] args) => 123 | throw new NotImplementedException(); 124 | 125 | public void Warn(Action formatMessageCallback) => 126 | throw new NotImplementedException(); 127 | 128 | public void Warn(Action formatMessageCallback, Exception exception) => 129 | throw new NotImplementedException(); 130 | 131 | public void Warn(IFormatProvider formatProvider, Action formatMessageCallback) => 132 | throw new NotImplementedException(); 133 | 134 | public void Warn(IFormatProvider formatProvider, Action formatMessageCallback, Exception exception) => 135 | throw new NotImplementedException(); 136 | 137 | public void Error(object message) => 138 | throw new NotImplementedException(); 139 | 140 | public void Error(object message, Exception exception) => 141 | throw new NotImplementedException(); 142 | 143 | public void ErrorFormat(string format, params object[] args) => 144 | throw new NotImplementedException(); 145 | 146 | public void ErrorFormat(string format, Exception exception, params object[] args) => 147 | throw new NotImplementedException(); 148 | 149 | public void ErrorFormat(IFormatProvider formatProvider, string format, params object[] args) => 150 | throw new NotImplementedException(); 151 | 152 | public void ErrorFormat(IFormatProvider formatProvider, string format, Exception exception, params object[] args) => 153 | throw new NotImplementedException(); 154 | 155 | public void Error(Action formatMessageCallback) => 156 | throw new NotImplementedException(); 157 | 158 | public void Error(Action formatMessageCallback, Exception exception) => 159 | throw new NotImplementedException(); 160 | 161 | public void Error(IFormatProvider formatProvider, Action formatMessageCallback) => 162 | throw new NotImplementedException(); 163 | 164 | public void Error(IFormatProvider formatProvider, Action formatMessageCallback, Exception exception) => 165 | throw new NotImplementedException(); 166 | 167 | public void Fatal(object message) => 168 | throw new NotImplementedException(); 169 | 170 | public void Fatal(object message, Exception exception) => 171 | throw new NotImplementedException(); 172 | 173 | public void FatalFormat(string format, params object[] args) => 174 | throw new NotImplementedException(); 175 | 176 | public void FatalFormat(string format, Exception exception, params object[] args) => 177 | throw new NotImplementedException(); 178 | 179 | public void FatalFormat(IFormatProvider formatProvider, string format, params object[] args) => 180 | throw new NotImplementedException(); 181 | 182 | public void FatalFormat(IFormatProvider formatProvider, string format, Exception exception, params object[] args) => 183 | throw new NotImplementedException(); 184 | 185 | public void Fatal(Action formatMessageCallback) => 186 | throw new NotImplementedException(); 187 | 188 | public void Fatal(Action formatMessageCallback, Exception exception) => 189 | throw new NotImplementedException(); 190 | 191 | public void Fatal(IFormatProvider formatProvider, Action formatMessageCallback) => 192 | throw new NotImplementedException(); 193 | 194 | public void Fatal(IFormatProvider formatProvider, Action formatMessageCallback, Exception exception) => 195 | throw new NotImplementedException(); 196 | 197 | public bool IsTraceEnabled { get; private set; } 198 | public bool IsDebugEnabled => true; 199 | public bool IsErrorEnabled { get; private set; } 200 | public bool IsFatalEnabled { get; private set; } 201 | public bool IsInfoEnabled { get; private set; } 202 | public bool IsWarnEnabled { get; private set; } 203 | 204 | public IVariablesContext GlobalVariablesContext => throw new NotImplementedException(); 205 | 206 | public IVariablesContext ThreadVariablesContext => throw new NotImplementedException(); 207 | 208 | public INestedVariablesContext NestedThreadVariablesContext { get; } 209 | } -------------------------------------------------------------------------------- /FodyAddinSamples.sln: -------------------------------------------------------------------------------- 1 | Microsoft Visual Studio Solution File, Format Version 12.00 2 | # Visual Studio Version 16 3 | VisualStudioVersion = 16.0.29201.188 4 | MinimumVisualStudioVersion = 16.0.29201.188 5 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Weavers", "Weavers\Weavers.csproj", "{480773F7-4696-4B7E-BE33-11005417BE13}" 6 | EndProject 7 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Samples", "Samples\Samples.csproj", "{0442EB29-A385-41FD-BBBF-936C562235A8}" 8 | ProjectSection(ProjectDependencies) = postProject 9 | {480773F7-4696-4B7E-BE33-11005417BE13} = {480773F7-4696-4B7E-BE33-11005417BE13} 10 | EndProjectSection 11 | EndProject 12 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CosturaSample", "CosturaSample\CosturaSample.csproj", "{8C6D118C-4FB5-4334-8DB7-BFEFADAC41F8}" 13 | EndProject 14 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CosturaAssemblyToReference", "CosturaAssemblyToReference\CosturaAssemblyToReference.csproj", "{84D7F752-71BE-45D1-89B1-6514508CC5EA}" 15 | EndProject 16 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NullGuardSample", "NullGuardSample\NullGuardSample.csproj", "{F82F7891-C5D2-4D02-A766-8ADEBAAE3DFF}" 17 | EndProject 18 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "InlineILSample", "InlineILSample\InlineILSample.csproj", "{7931D18D-0C53-4037-9BDD-022BBD9BA1C2}" 19 | EndProject 20 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ThrottleSample", "ThrottleSample\ThrottleSample.csproj", "{F09643AC-3890-4E35-99FC-231809C55356}" 21 | EndProject 22 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CatelSample", "CatelSample\CatelSample.csproj", "{8D381E80-E9BB-4B8E-AF8A-819C3534176C}" 23 | EndProject 24 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WeakEventHandlerSample", "WeakEventHandlerSample\WeakEventHandlerSample.csproj", "{578E811C-C350-4487-B3EE-1345FEC27B67}" 25 | EndProject 26 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ToStringSample", "ToStringSample\ToStringSample.csproj", "{AF91A2D4-58D3-4772-A41A-7EF0139CD0F2}" 27 | EndProject 28 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "InSolutionWeaving", "InSolutionWeaving\InSolutionWeaving.csproj", "{6E5EB9C2-705E-48F2-9A53-7957F33540B0}" 29 | EndProject 30 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{FC6E6AEA-BFCA-4E64-B8EE-5A4223EE75FB}" 31 | ProjectSection(SolutionItems) = preProject 32 | Directory.Build.props = Directory.Build.props 33 | .editorconfig = .editorconfig 34 | appveyor.yml = appveyor.yml 35 | EndProjectSection 36 | EndProject 37 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LocalsInitSample", "LocalsInitSample\LocalsInitSample.csproj", "{DC05FD6E-9FEE-4BB9-910A-A305E61ED33C}" 38 | EndProject 39 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ReactiveUISample", "ReactiveUISample\ReactiveUISample.csproj", "{0A2F7C38-8F55-44FA-BE5C-6CE9BBF3AD1A}" 40 | EndProject 41 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MethodDecoratorSample", "MethodDecoratorSample\MethodDecoratorSample.csproj", "{E3F286A2-556C-492A-8836-6819B38140B3}" 42 | EndProject 43 | Global 44 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 45 | Debug|Any CPU = Debug|Any CPU 46 | Release|Any CPU = Release|Any CPU 47 | ReleaseNetCore|Any CPU = ReleaseNetCore|Any CPU 48 | EndGlobalSection 49 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 50 | {480773F7-4696-4B7E-BE33-11005417BE13}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 51 | {480773F7-4696-4B7E-BE33-11005417BE13}.Debug|Any CPU.Build.0 = Debug|Any CPU 52 | {480773F7-4696-4B7E-BE33-11005417BE13}.Release|Any CPU.ActiveCfg = Release|Any CPU 53 | {480773F7-4696-4B7E-BE33-11005417BE13}.Release|Any CPU.Build.0 = Release|Any CPU 54 | {480773F7-4696-4B7E-BE33-11005417BE13}.ReleaseNetCore|Any CPU.ActiveCfg = Release|Any CPU 55 | {0442EB29-A385-41FD-BBBF-936C562235A8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 56 | {0442EB29-A385-41FD-BBBF-936C562235A8}.Debug|Any CPU.Build.0 = Debug|Any CPU 57 | {0442EB29-A385-41FD-BBBF-936C562235A8}.Release|Any CPU.ActiveCfg = Release|Any CPU 58 | {0442EB29-A385-41FD-BBBF-936C562235A8}.Release|Any CPU.Build.0 = Release|Any CPU 59 | {0442EB29-A385-41FD-BBBF-936C562235A8}.ReleaseNetCore|Any CPU.ActiveCfg = Release|Any CPU 60 | {0442EB29-A385-41FD-BBBF-936C562235A8}.ReleaseNetCore|Any CPU.Build.0 = Release|Any CPU 61 | {8C6D118C-4FB5-4334-8DB7-BFEFADAC41F8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 62 | {8C6D118C-4FB5-4334-8DB7-BFEFADAC41F8}.Debug|Any CPU.Build.0 = Debug|Any CPU 63 | {8C6D118C-4FB5-4334-8DB7-BFEFADAC41F8}.Release|Any CPU.ActiveCfg = Release|Any CPU 64 | {8C6D118C-4FB5-4334-8DB7-BFEFADAC41F8}.Release|Any CPU.Build.0 = Release|Any CPU 65 | {8C6D118C-4FB5-4334-8DB7-BFEFADAC41F8}.ReleaseNetCore|Any CPU.ActiveCfg = Release|Any CPU 66 | {84D7F752-71BE-45D1-89B1-6514508CC5EA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 67 | {84D7F752-71BE-45D1-89B1-6514508CC5EA}.Debug|Any CPU.Build.0 = Debug|Any CPU 68 | {84D7F752-71BE-45D1-89B1-6514508CC5EA}.Release|Any CPU.ActiveCfg = Release|Any CPU 69 | {84D7F752-71BE-45D1-89B1-6514508CC5EA}.Release|Any CPU.Build.0 = Release|Any CPU 70 | {84D7F752-71BE-45D1-89B1-6514508CC5EA}.ReleaseNetCore|Any CPU.ActiveCfg = Release|Any CPU 71 | {F82F7891-C5D2-4D02-A766-8ADEBAAE3DFF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 72 | {F82F7891-C5D2-4D02-A766-8ADEBAAE3DFF}.Debug|Any CPU.Build.0 = Debug|Any CPU 73 | {F82F7891-C5D2-4D02-A766-8ADEBAAE3DFF}.Release|Any CPU.ActiveCfg = Release|Any CPU 74 | {F82F7891-C5D2-4D02-A766-8ADEBAAE3DFF}.Release|Any CPU.Build.0 = Release|Any CPU 75 | {F82F7891-C5D2-4D02-A766-8ADEBAAE3DFF}.ReleaseNetCore|Any CPU.ActiveCfg = Release|Any CPU 76 | {7931D18D-0C53-4037-9BDD-022BBD9BA1C2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 77 | {7931D18D-0C53-4037-9BDD-022BBD9BA1C2}.Debug|Any CPU.Build.0 = Debug|Any CPU 78 | {7931D18D-0C53-4037-9BDD-022BBD9BA1C2}.Release|Any CPU.ActiveCfg = Release|Any CPU 79 | {7931D18D-0C53-4037-9BDD-022BBD9BA1C2}.Release|Any CPU.Build.0 = Release|Any CPU 80 | {7931D18D-0C53-4037-9BDD-022BBD9BA1C2}.ReleaseNetCore|Any CPU.ActiveCfg = Release|Any CPU 81 | {F09643AC-3890-4E35-99FC-231809C55356}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 82 | {F09643AC-3890-4E35-99FC-231809C55356}.Debug|Any CPU.Build.0 = Debug|Any CPU 83 | {F09643AC-3890-4E35-99FC-231809C55356}.Release|Any CPU.ActiveCfg = Release|Any CPU 84 | {F09643AC-3890-4E35-99FC-231809C55356}.Release|Any CPU.Build.0 = Release|Any CPU 85 | {F09643AC-3890-4E35-99FC-231809C55356}.ReleaseNetCore|Any CPU.ActiveCfg = Release|Any CPU 86 | {8D381E80-E9BB-4B8E-AF8A-819C3534176C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 87 | {8D381E80-E9BB-4B8E-AF8A-819C3534176C}.Debug|Any CPU.Build.0 = Debug|Any CPU 88 | {8D381E80-E9BB-4B8E-AF8A-819C3534176C}.Release|Any CPU.ActiveCfg = Release|Any CPU 89 | {8D381E80-E9BB-4B8E-AF8A-819C3534176C}.Release|Any CPU.Build.0 = Release|Any CPU 90 | {8D381E80-E9BB-4B8E-AF8A-819C3534176C}.ReleaseNetCore|Any CPU.ActiveCfg = Release|Any CPU 91 | {578E811C-C350-4487-B3EE-1345FEC27B67}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 92 | {578E811C-C350-4487-B3EE-1345FEC27B67}.Debug|Any CPU.Build.0 = Debug|Any CPU 93 | {578E811C-C350-4487-B3EE-1345FEC27B67}.Release|Any CPU.ActiveCfg = Release|Any CPU 94 | {578E811C-C350-4487-B3EE-1345FEC27B67}.Release|Any CPU.Build.0 = Release|Any CPU 95 | {578E811C-C350-4487-B3EE-1345FEC27B67}.ReleaseNetCore|Any CPU.ActiveCfg = Release|Any CPU 96 | {AF91A2D4-58D3-4772-A41A-7EF0139CD0F2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 97 | {AF91A2D4-58D3-4772-A41A-7EF0139CD0F2}.Debug|Any CPU.Build.0 = Debug|Any CPU 98 | {AF91A2D4-58D3-4772-A41A-7EF0139CD0F2}.Release|Any CPU.ActiveCfg = Release|Any CPU 99 | {AF91A2D4-58D3-4772-A41A-7EF0139CD0F2}.Release|Any CPU.Build.0 = Release|Any CPU 100 | {AF91A2D4-58D3-4772-A41A-7EF0139CD0F2}.ReleaseNetCore|Any CPU.ActiveCfg = Release|Any CPU 101 | {6E5EB9C2-705E-48F2-9A53-7957F33540B0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 102 | {6E5EB9C2-705E-48F2-9A53-7957F33540B0}.Debug|Any CPU.Build.0 = Debug|Any CPU 103 | {6E5EB9C2-705E-48F2-9A53-7957F33540B0}.Release|Any CPU.ActiveCfg = Release|Any CPU 104 | {6E5EB9C2-705E-48F2-9A53-7957F33540B0}.Release|Any CPU.Build.0 = Release|Any CPU 105 | {6E5EB9C2-705E-48F2-9A53-7957F33540B0}.ReleaseNetCore|Any CPU.ActiveCfg = Release|Any CPU 106 | {DC05FD6E-9FEE-4BB9-910A-A305E61ED33C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 107 | {DC05FD6E-9FEE-4BB9-910A-A305E61ED33C}.Debug|Any CPU.Build.0 = Debug|Any CPU 108 | {DC05FD6E-9FEE-4BB9-910A-A305E61ED33C}.Release|Any CPU.ActiveCfg = Release|Any CPU 109 | {DC05FD6E-9FEE-4BB9-910A-A305E61ED33C}.Release|Any CPU.Build.0 = Release|Any CPU 110 | {DC05FD6E-9FEE-4BB9-910A-A305E61ED33C}.ReleaseNetCore|Any CPU.ActiveCfg = Release|Any CPU 111 | {0A2F7C38-8F55-44FA-BE5C-6CE9BBF3AD1A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 112 | {0A2F7C38-8F55-44FA-BE5C-6CE9BBF3AD1A}.Debug|Any CPU.Build.0 = Debug|Any CPU 113 | {0A2F7C38-8F55-44FA-BE5C-6CE9BBF3AD1A}.Release|Any CPU.ActiveCfg = Release|Any CPU 114 | {0A2F7C38-8F55-44FA-BE5C-6CE9BBF3AD1A}.Release|Any CPU.Build.0 = Release|Any CPU 115 | {0A2F7C38-8F55-44FA-BE5C-6CE9BBF3AD1A}.ReleaseNetCore|Any CPU.ActiveCfg = Release|Any CPU 116 | {0A2F7C38-8F55-44FA-BE5C-6CE9BBF3AD1A}.ReleaseNetCore|Any CPU.Build.0 = Release|Any CPU 117 | {E3F286A2-556C-492A-8836-6819B38140B3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 118 | {E3F286A2-556C-492A-8836-6819B38140B3}.Debug|Any CPU.Build.0 = Debug|Any CPU 119 | {E3F286A2-556C-492A-8836-6819B38140B3}.Release|Any CPU.ActiveCfg = Release|Any CPU 120 | {E3F286A2-556C-492A-8836-6819B38140B3}.Release|Any CPU.Build.0 = Release|Any CPU 121 | {E3F286A2-556C-492A-8836-6819B38140B3}.ReleaseNetCore|Any CPU.ActiveCfg = Debug|Any CPU 122 | {E3F286A2-556C-492A-8836-6819B38140B3}.ReleaseNetCore|Any CPU.Build.0 = Debug|Any CPU 123 | EndGlobalSection 124 | GlobalSection(SolutionProperties) = preSolution 125 | HideSolutionNode = FALSE 126 | EndGlobalSection 127 | GlobalSection(ExtensibilityGlobals) = postSolution 128 | SolutionGuid = {345B3A84-DB0C-4BB3-AD82-EDA762D35493} 129 | EndGlobalSection 130 | GlobalSection(CodealikeProperties) = postSolution 131 | SolutionGuid = 2f38512b-20a3-4f87-a0bf-c9e919c18c12 132 | EndGlobalSection 133 | GlobalSection(MonoDevelopProperties) = preSolution 134 | StartupItem = PropertyChangedSample\PropertyChangedSample.csproj 135 | EndGlobalSection 136 | EndGlobal 137 | -------------------------------------------------------------------------------- /FodyAddinSamples.sln.DotSettings: -------------------------------------------------------------------------------- 1 | 2 | True 3 | ERROR 4 | ERROR 5 | ERROR 6 | ERROR 7 | HINT 8 | ERROR 9 | ERROR 10 | ERROR 11 | HINT 12 | HINT 13 | DO_NOT_SHOW 14 | ERROR 15 | HINT 16 | ERROR 17 | ERROR 18 | ERROR 19 | ERROR 20 | ERROR 21 | ERROR 22 | ERROR 23 | ERROR 24 | ERROR 25 | ERROR 26 | ERROR 27 | ERROR 28 | ERROR 29 | ERROR 30 | ERROR 31 | ERROR 32 | ERROR 33 | ERROR 34 | ERROR 35 | HINT 36 | HINT 37 | ERROR 38 | ERROR 39 | ERROR 40 | ERROR 41 | ERROR 42 | ERROR 43 | ERROR 44 | ERROR 45 | ERROR 46 | ERROR 47 | ERROR 48 | ERROR 49 | ERROR 50 | ERROR 51 | ERROR 52 | ERROR 53 | ERROR 54 | ERROR 55 | ERROR 56 | ERROR 57 | ERROR 58 | ERROR 59 | ERROR 60 | ERROR 61 | ERROR 62 | ERROR 63 | ERROR 64 | ERROR 65 | ERROR 66 | ERROR 67 | ERROR 68 | ERROR 69 | ERROR 70 | ERROR 71 | ERROR 72 | ERROR 73 | ERROR 74 | ERROR 75 | ERROR 76 | ERROR 77 | ERROR 78 | ERROR 79 | ERROR 80 | ERROR 81 | ERROR 82 | ERROR 83 | ERROR 84 | ERROR 85 | ERROR 86 | ERROR 87 | ERROR 88 | ERROR 89 | ERROR 90 | ERROR 91 | ERROR 92 | ERROR 93 | ERROR 94 | ERROR 95 | ERROR 96 | ERROR 97 | ERROR 98 | ERROR 99 | ERROR 100 | ERROR 101 | ERROR 102 | ERROR 103 | ERROR 104 | ERROR 105 | ERROR 106 | ERROR 107 | ERROR 108 | ERROR 109 | Required 110 | Required 111 | Required 112 | Required 113 | Implicit 114 | Implicit 115 | ERROR 116 | ERROR 117 | True 118 | NEVER 119 | True 120 | False 121 | <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> 122 | <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> 123 | <Policy><Descriptor Staticness="Instance" AccessRightKinds="Private" Description="Instance fields (private)"><ElementKinds><Kind Name="FIELD" /><Kind Name="READONLY_FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /></Policy> 124 | <Policy><Descriptor Staticness="Static" AccessRightKinds="Private" Description="Static fields (private)"><ElementKinds><Kind Name="FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /></Policy> 125 | True 126 | True 127 | True 128 | True 129 | True 130 | True 131 | True 132 | True 133 | True 134 | True 135 | True 136 | True 137 | --------------------------------------------------------------------------------