Skip to content

Commit

Permalink
Use AssemblyLoader.Create() in demo app.
Browse files Browse the repository at this point in the history
  • Loading branch information
dgrunwald committed Jun 22, 2013
1 parent 261a57d commit cc65281
Show file tree
Hide file tree
Showing 14 changed files with 172 additions and 221 deletions.
2 changes: 1 addition & 1 deletion ICSharpCode.NRefactory.CSharp/Refactoring/Script.cs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ public void ChangeModifier(EntityDeclaration entity, Modifiers modifiers)
/// Adds an attribute section to a given entity.
/// </summary>
/// <param name="entity">The entity to add the attribute to.</param>
/// <param name="Attribute">The attribute to add.</param>
/// <param name="attr">The attribute to add.</param>
public void AddAttribute(EntityDeclaration entity, AttributeSection attr)
{
var node = entity.FirstChild;
Expand Down
31 changes: 1 addition & 30 deletions ICSharpCode.NRefactory.Cecil/CecilLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,7 @@ public sealed class CecilLoader : AssemblyLoader
const int cecilLoaderVersion = 1;

#region Options
/// <summary>
/// Specifies whether to include internal members. The default is false.
/// </summary>
public bool IncludeInternalMembers { get; set; }
// Most options are defined in the AssemblyLoader base class

/// <summary>
/// Specifies whether to use lazy loading. The default is false.
Expand All @@ -68,30 +65,6 @@ public sealed class CecilLoader : AssemblyLoader
/// </remarks>
public bool LazyLoad { get; set; }

/// <summary>
/// Gets/Sets the documentation provider that is used to retrieve the XML documentation for all members.
/// </summary>
public IDocumentationProvider DocumentationProvider { get; set; }

InterningProvider interningProvider;

/// <summary>
/// Gets/Sets the interning provider.
/// </summary>
public InterningProvider InterningProvider {
get { return interningProvider; }
set {
if (value == null)
throw new ArgumentNullException();
interningProvider = value;
}
}

/// <summary>
/// Gets/Sets the cancellation token used by the cecil loader.
/// </summary>
public CancellationToken CancellationToken { get; set; }

/// <summary>
/// This delegate gets executed whenever an entity was loaded.
/// </summary>
Expand Down Expand Up @@ -120,8 +93,6 @@ public InterningProvider InterningProvider {
/// </summary>
public CecilLoader()
{
// Enable interning by default.
this.InterningProvider = new SimpleInterningProvider();
}

/// <summary>
Expand Down
105 changes: 54 additions & 51 deletions ICSharpCode.NRefactory.Cecil/ICSharpCode.NRefactory.Cecil.csproj
Original file line number Diff line number Diff line change
@@ -1,52 +1,55 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>10.0.0</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{2B8F4F83-C2B3-4E84-A27B-8DEE1BE0E006}</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>ICSharpCode.NRefactory.Cecil</RootNamespace>
<AssemblyName>ICSharpCode.NRefactory.Cecil</AssemblyName>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\ICSharpCode.NRefactory.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>full</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="CecilLoader.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
<ProjectReference Include="..\ICSharpCode.NRefactory\ICSharpCode.NRefactory.csproj">
<Project>{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}</Project>
<Name>ICSharpCode.NRefactory</Name>
</ProjectReference>
<ProjectReference Include="..\..\cecil\Mono.Cecil.csproj">
<Project>{D68133BD-1E63-496E-9EDE-4FBDBF77B486}</Project>
<Name>Mono.Cecil</Name>
</ProjectReference>
</ItemGroup>
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>10.0.0</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{2B8F4F83-C2B3-4E84-A27B-8DEE1BE0E006}</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>ICSharpCode.NRefactory.Cecil</RootNamespace>
<AssemblyName>ICSharpCode.NRefactory.Cecil</AssemblyName>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\ICSharpCode.NRefactory.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>full</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\ICSharpCode.NRefactory\Properties\GlobalAssemblyInfo.cs">
<Link>Properties\GlobalAssemblyInfo.cs</Link>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="CecilLoader.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
<ProjectReference Include="..\ICSharpCode.NRefactory\ICSharpCode.NRefactory.csproj">
<Project>{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}</Project>
<Name>ICSharpCode.NRefactory</Name>
</ProjectReference>
<ProjectReference Include="..\..\cecil\Mono.Cecil.csproj">
<Project>{D68133BD-1E63-496E-9EDE-4FBDBF77B486}</Project>
<Name>Mono.Cecil</Name>
</ProjectReference>
</ItemGroup>
</Project>
24 changes: 4 additions & 20 deletions ICSharpCode.NRefactory.Cecil/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,30 +23,14 @@
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

using System;
using System.Reflection;
using System.Runtime.CompilerServices;

// Information about this assembly is defined by the following attributes.
// Change them to the values specific to your project.

[assembly: AssemblyTitle("ICSharpCode.NRefactory.Cecil")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("Xamarin Inc. (http://xamarin.com)")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
// and "{Major}.{Minor}.{Build}.*" will update just the revision.

[assembly: AssemblyVersion("1.0.*")]

// The following attributes are used to specify the signing key for the assembly,
// if desired. See the Mono documentation for more information about signing.

//[assembly: AssemblyDelaySign(false)]
//[assembly: AssemblyKeyFile("")]
[assembly: AssemblyDescription("Cecil Assembly Loader for NRefactory")]

[assembly: CLSCompliant(true)]
2 changes: 1 addition & 1 deletion ICSharpCode.NRefactory.ConsistencyCheck/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ static void RunTestOnAllFiles(string title, Action<CSharpFile> runTest)

public static IUnresolvedAssembly LoadAssembly(string assemblyFileName)
{
return assemblyDict.GetOrAdd(assemblyFileName, file => new CecilLoader().LoadAssemblyFile(file));
return assemblyDict.GetOrAdd(assemblyFileName, file => AssemblyLoader.Create().LoadAssemblyFile(file));
}
}

Expand Down
2 changes: 1 addition & 1 deletion ICSharpCode.NRefactory.ConsistencyCheck/Solution.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public Solution(string fileName)
/// </summary>
public IUnresolvedAssembly LoadAssembly(string assemblyFileName)
{
return assemblyDict.GetOrAdd(assemblyFileName, file => new CecilLoader().LoadAssemblyFile(file));
return assemblyDict.GetOrAdd(assemblyFileName, file => AssemblyLoader.Create().LoadAssemblyFile(file));
}
}
}
2 changes: 1 addition & 1 deletion ICSharpCode.NRefactory.Demo/CSDemo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ void CSharpTreeViewAfterSelect(object sender, TreeViewEventArgs e)
0, assemblies.Length,
delegate (int i) {
Stopwatch w = Stopwatch.StartNew();
CecilLoader loader = new CecilLoader();
AssemblyLoader loader = AssemblyLoader.Create();
projectContents[i] = loader.LoadAssemblyFile(assemblies[i].Location);
Debug.WriteLine(Path.GetFileName(assemblies[i].Location) + ": " + w.Elapsed);
});
Expand Down
2 changes: 1 addition & 1 deletion ICSharpCode.NRefactory.GtkDemo/MainWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ void HandleClicked (object sender, EventArgs e)
0, assemblies.Length,
delegate (int i) {
Stopwatch w = Stopwatch.StartNew();
CecilLoader loader = new CecilLoader();
AssemblyLoader loader = AssemblyLoader.Create();
projectContents[i] = loader.LoadAssemblyFile(assemblies[i].Location);
});
return projectContents;
Expand Down
107 changes: 55 additions & 52 deletions ICSharpCode.NRefactory.IKVM/ICSharpCode.NRefactory.IKVM.csproj
Original file line number Diff line number Diff line change
@@ -1,53 +1,56 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>10.0.0</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{A727169F-D94F-443F-B305-B057D7F3B420}</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>ICSharpCode.NRefactory.IKVM</RootNamespace>
<AssemblyName>ICSharpCode.NRefactory.IKVM</AssemblyName>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\ICSharpCode.NRefactory.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>full</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
<ProjectReference Include="..\..\ikvm-fork\reflect\IKVM.Reflection.csproj">
<Project>{4CB170EF-DFE6-4A56-9E1B-A85449E827A7}</Project>
<Name>IKVM.Reflection</Name>
</ProjectReference>
<ProjectReference Include="..\ICSharpCode.NRefactory\ICSharpCode.NRefactory.csproj">
<Project>{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}</Project>
<Name>ICSharpCode.NRefactory</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="IkvmLoader.cs" />
</ItemGroup>
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>10.0.0</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{A727169F-D94F-443F-B305-B057D7F3B420}</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>ICSharpCode.NRefactory.IKVM</RootNamespace>
<AssemblyName>ICSharpCode.NRefactory.IKVM</AssemblyName>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\ICSharpCode.NRefactory.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>full</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\ICSharpCode.NRefactory\Properties\GlobalAssemblyInfo.cs">
<Link>Properties\GlobalAssemblyInfo.cs</Link>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
<ProjectReference Include="..\..\ikvm-fork\reflect\IKVM.Reflection.csproj">
<Project>{4CB170EF-DFE6-4A56-9E1B-A85449E827A7}</Project>
<Name>IKVM.Reflection</Name>
</ProjectReference>
<ProjectReference Include="..\ICSharpCode.NRefactory\ICSharpCode.NRefactory.csproj">
<Project>{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}</Project>
<Name>ICSharpCode.NRefactory</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="IkvmLoader.cs" />
</ItemGroup>
</Project>
33 changes: 2 additions & 31 deletions ICSharpCode.NRefactory.IKVM/IkvmLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,35 +57,8 @@ public sealed class IkvmLoader : AssemblyLoader
const int ikvmLoaderVersion = 1;

#region Options
/// <summary>
/// Specifies whether to include internal members. The default is false.
/// </summary>
public bool IncludeInternalMembers { get; set; }

/// <summary>
/// Gets/Sets the documentation provider that is used to retrieve the XML documentation for all members.
/// </summary>
public IDocumentationProvider DocumentationProvider { get; set; }

InterningProvider interningProvider;

/// <summary>
/// Gets/Sets the interning provider.
/// </summary>
public InterningProvider InterningProvider {
get { return interningProvider; }
set {
if (value == null)
throw new ArgumentNullException();
interningProvider = value;
}
}

/// <summary>
/// Gets/Sets the cancellation token used by the cecil loader.
/// </summary>
public CancellationToken CancellationToken { get; set; }

// Most options are defined in the AssemblyLoader base class

/// <summary>
/// This delegate gets executed whenever an entity was loaded.
/// </summary>
Expand All @@ -103,8 +76,6 @@ public InterningProvider InterningProvider {
/// </summary>
public IkvmLoader()
{
// Enable interning by default.
this.InterningProvider = new SimpleInterningProvider();
}

#region Load Assembly From Disk
Expand Down
Loading

0 comments on commit cc65281

Please sign in to comment.