Skip to content

Commit

Permalink
Bugfix in Fody weaving.
Browse files Browse the repository at this point in the history
References #20.
  • Loading branch information
jspuij committed Nov 15, 2019
1 parent 6840db3 commit c0bc3e3
Show file tree
Hide file tree
Showing 23 changed files with 116 additions and 70 deletions.
2 changes: 1 addition & 1 deletion build/build.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
<PackageProjectUrl>https://github.com/jspuij/Cortex.Net</PackageProjectUrl>
<DisableFody>true</DisableFody>
<Version>0.1.0-preview</Version>
<Version>0.1.0-preview2</Version>
<NeutralLanguage>en-US</NeutralLanguage>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion samples/Cortex.Net.BlazorTodo/Cortex.Net.BlazorTodo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<ItemGroup>
<ProjectReference Include="..\..\src\Cortex.Net.Blazor\Cortex.Net.Blazor.csproj" />
<ProjectReference Include="..\..\src\Cortex.Net\Cortex.Net.csproj" />
<WeaverFiles Include="$(SolutionDir)src\Cortex.Net.Fody\bin\$(Configuration)\netstandard2.0\Cortex.Net.Fody.dll" WeaverClassNames="CortexWeaver" />
<WeaverFiles Include="$(SolutionDir)src\Cortex.Net.Fody\bin\$(Configuration)\netstandard2.0\Cortex.Net.Fody.dll" WeaverClassNames="ModuleWeaver" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion samples/Cortex.Net.BlazorTodo/FodyWeavers.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Weavers VerifyAssembly="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
<CortexWeaver />
<ModuleWeaver />
</Weavers>
2 changes: 1 addition & 1 deletion samples/Cortex.Net.BlazorTodo/FodyWeavers.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<xs:element name="Weavers">
<xs:complexType>
<xs:all>
<xs:element name="CortexWeaver" minOccurs="0" maxOccurs="1" type="xs:anyType" />
<xs:element name="ModuleWeaver" minOccurs="0" maxOccurs="1" type="xs:anyType" />
</xs:all>
<xs:attribute name="VerifyAssembly" type="xs:boolean">
<xs:annotation>
Expand Down
4 changes: 2 additions & 2 deletions src/Cortex.Net.Fody/ActionWeaver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ internal class ActionWeaver
/// <summary>
/// A reference to the parent Cortex.Net weaver.
/// </summary>
private readonly CortexWeaver parentWeaver;
private readonly ModuleWeaver parentWeaver;

/// <summary>
/// The queue to add ILProcessor actions to.
Expand All @@ -62,7 +62,7 @@ internal class ActionWeaver
/// <param name="processorQueue">The queue to add ILProcessor actions to.</param>
/// <param name="weavingContext">The resolved types necessary by this weaver.</param>
/// <exception cref="ArgumentNullException">When any of the arguments is null.</exception>
public ActionWeaver(CortexWeaver parentWeaver, ISharedStateAssignmentILProcessorQueue processorQueue, WeavingContext weavingContext)
public ActionWeaver(ModuleWeaver parentWeaver, ISharedStateAssignmentILProcessorQueue processorQueue, WeavingContext weavingContext)
{
this.parentWeaver = parentWeaver ?? throw new ArgumentNullException(nameof(parentWeaver));
this.processorQueue = processorQueue ?? throw new ArgumentNullException(nameof(processorQueue));
Expand Down
4 changes: 2 additions & 2 deletions src/Cortex.Net.Fody/BlazorObserverWeaver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ public class BlazorObserverWeaver
/// <summary>
/// The parent weaver.
/// </summary>
private readonly CortexWeaver parentWeaver;
private readonly ModuleWeaver parentWeaver;

/// <summary>
/// Initializes a new instance of the <see cref="BlazorObserverWeaver"/> class.
/// </summary>
/// <param name="parentWeaver">The parent weaver of this weaver.</param>
/// <param name="processorQueue">The processor queue to add delegates to, to be executed on ISharedState property assignment.</param>
/// <param name="weavingContext">The resolved types necessary by this weaver.</param>
public BlazorObserverWeaver(CortexWeaver parentWeaver, ISharedStateAssignmentILProcessorQueue processorQueue, BlazorWeavingContext weavingContext)
public BlazorObserverWeaver(ModuleWeaver parentWeaver, ISharedStateAssignmentILProcessorQueue processorQueue, BlazorWeavingContext weavingContext)
{
this.parentWeaver = parentWeaver ?? throw new ArgumentNullException(nameof(parentWeaver));
this.processorQueue = processorQueue ?? throw new ArgumentNullException(nameof(processorQueue));
Expand Down
2 changes: 1 addition & 1 deletion src/Cortex.Net.Fody/BlazorWeavingContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class BlazorWeavingContext : WeavingContext
/// Initializes a new instance of the <see cref="BlazorWeavingContext"/> class.
/// </summary>
/// <param name="moduleWeaver">Moduleweaver to use.</param>
public BlazorWeavingContext(CortexWeaver moduleWeaver)
public BlazorWeavingContext(ModuleWeaver moduleWeaver)
: base(moduleWeaver)
{
this.CortexNetBlazorObserverAttribute = TryResolveFromReference(moduleWeaver, "Cortex.Net.Blazor.ObserverAttribute", "Cortex.Net.Blazor");
Expand Down
2 changes: 1 addition & 1 deletion src/Cortex.Net.Fody/ComputedWeaver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ internal class ComputedWeaver : ObservableObjectWeaverBase
/// <param name="processorQueue">The queue to add ILProcessor actions to.</param>
/// <exception cref="ArgumentNullException">When any of the arguments is null.</exception>
/// <param name="weavingContext">The resolved types necessary by this weaver.</param>
public ComputedWeaver(CortexWeaver parentWeaver, ISharedStateAssignmentILProcessorQueue processorQueue, WeavingContext weavingContext)
public ComputedWeaver(ModuleWeaver parentWeaver, ISharedStateAssignmentILProcessorQueue processorQueue, WeavingContext weavingContext)
: base(parentWeaver, processorQueue, weavingContext)
{
}
Expand Down
68 changes: 39 additions & 29 deletions src/Cortex.Net.Fody/Cortex.Net.Fody.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/Cortex.Net.Fody/EnumerableInterfaceWeaver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public class EnumerableInterfaceWeaver : IEnumerableInterfaceWeaver
/// <summary>
/// The parent weaver of this weaver.
/// </summary>
private readonly CortexWeaver parentWeaver;
private readonly ModuleWeaver parentWeaver;

/// <summary>
/// The processor queue that contains delegates to be processed when the shared state is assigned.
Expand All @@ -68,7 +68,7 @@ public class EnumerableInterfaceWeaver : IEnumerableInterfaceWeaver
/// <param name="parentWeaver">The parent weaver of this CollectionWeaver.</param>
/// <param name="processorQueue">The queue to add ILProcessor actions to.</param>
/// <param name="weavingContext">The resolved types necessary by this weaver.</param>
public EnumerableInterfaceWeaver(CortexWeaver parentWeaver, ISharedStateAssignmentILProcessorQueue processorQueue, WeavingContext weavingContext)
public EnumerableInterfaceWeaver(ModuleWeaver parentWeaver, ISharedStateAssignmentILProcessorQueue processorQueue, WeavingContext weavingContext)
{
this.parentWeaver = parentWeaver ?? throw new ArgumentNullException(nameof(parentWeaver));
this.processorQueue = processorQueue ?? throw new ArgumentNullException(nameof(processorQueue));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// <copyright file="CortexWeaver.cs" company="Jan-Willem Spuij">
// <copyright file="ModuleWeaver.cs" company="Jan-Willem Spuij">
// Copyright 2019 Jan-Willem Spuij
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
Expand Down Expand Up @@ -28,17 +28,28 @@ namespace Cortex.Net.Fody
/// <summary>
/// Orchestrates weaving of classes with Cortex.Net Observables, Actions and Reactions.
/// </summary>
public class CortexWeaver : BaseModuleWeaver
public class ModuleWeaver : BaseModuleWeaver
{
/// <summary>
/// Executes the <see cref="CortexWeaver"/>.
/// Executes the <see cref="ModuleWeaver"/>.
/// </summary>
public override void Execute()
{
var weavingContext =
this.ModuleDefinition.AssemblyReferences.Any(x => x.Name == "Cortex.Net.Blazor") ?
new BlazorWeavingContext(this) :
new WeavingContext(this);
WeavingContext weavingContext = null;
try
{
weavingContext =
this.ModuleDefinition.AssemblyReferences.Any(x => x.Name == "Cortex.Net.Blazor") ?
new BlazorWeavingContext(this) :
new WeavingContext(this);
#pragma warning disable CA1031 // Do not catch general exception types
}
catch
#pragma warning restore CA1031 // Do not catch general exception types
{
this.LogWarning(Resources.CannotLoadTypes);
return;
}

var reactiveObjectInterfaceWeaver = new ReactiveObjectInterfaceWeaver(this, weavingContext);
var enumerableWeaver = new EnumerableInterfaceWeaver(this, reactiveObjectInterfaceWeaver, weavingContext);
Expand All @@ -62,7 +73,7 @@ public override void Execute()
}

/// <summary>
/// Return a list of assembly names for scanning. Used as a list for Fody.CortexWeaver.FindType.
/// Return a list of assembly names for scanning. Used as a list for Fody.ModuleWeaver.FindType.
/// </summary>
/// <returns>All types in the references assembly.</returns>
public override IEnumerable<string> GetAssembliesForScanning()
Expand Down
4 changes: 2 additions & 2 deletions src/Cortex.Net.Fody/ObservableObjectWeaverBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ internal abstract class ObservableObjectWeaverBase
/// <param name="parentWeaver">The parent weaver.</param>
/// <param name="processorQueue">The processor queue to add delegates to.</param>
/// <param name="weavingContext">The resolved types necessary by this weaver.</param>
protected ObservableObjectWeaverBase(CortexWeaver parentWeaver, ISharedStateAssignmentILProcessorQueue processorQueue, WeavingContext weavingContext)
protected ObservableObjectWeaverBase(ModuleWeaver parentWeaver, ISharedStateAssignmentILProcessorQueue processorQueue, WeavingContext weavingContext)
{
this.ParentWeaver = parentWeaver ?? throw new ArgumentNullException(nameof(parentWeaver));
this.ProcessorQueue = processorQueue ?? throw new ArgumentNullException(nameof(processorQueue));
Expand All @@ -50,7 +50,7 @@ protected ObservableObjectWeaverBase(CortexWeaver parentWeaver, ISharedStateAssi
/// <summary>
/// Gets the parent weaver of this Weaver.
/// </summary>
protected CortexWeaver ParentWeaver { get; private set; }
protected ModuleWeaver ParentWeaver { get; private set; }

/// <summary>
/// Gets the processor queue that contains delegates to be processed when the shared state is assigned.
Expand Down
Loading

0 comments on commit c0bc3e3

Please sign in to comment.