Browse Source

Added StyleCop.Analyzers to Perspex.Markup,Xaml.

pull/83/head
Steven Kirk 11 years ago
parent
commit
2520ae160a
  1. 14
      src/Markup/Perspex.Markup.Xaml/GlobalSuppressions.cs
  2. 5
      src/Markup/Perspex.Markup.Xaml/Perspex.Markup.Xaml.csproj
  3. 37
      src/Markup/Perspex.Markup.Xaml/PerspexXamlLoader.cs
  4. 1
      src/Markup/Perspex.Markup.Xaml/packages.config

14
src/Markup/Perspex.Markup.Xaml/GlobalSuppressions.cs

@ -0,0 +1,14 @@
// -----------------------------------------------------------------------
// <copyright file="GlobalSuppressions.cs" company="Steven Kirk">
// Copyright 2015 MIT Licence. See licence.md for more information.
// </copyright>
// -----------------------------------------------------------------------
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage(
"StyleCop.CSharp.MaintainabilityRules",
"SA1401:Fields must be private",
Justification = "PerspexProperty fields should not be private.")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage(
"StyleCop.CSharp.DocumentationRules",
"SA1609:Property documentation must have value",
Justification = "This rule is fscking pointless")]

5
src/Markup/Perspex.Markup.Xaml/Perspex.Markup.Xaml.csproj

@ -32,6 +32,7 @@
<DefineConstants>TRACE</DefineConstants> <DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Release\Perspex.Markup.Xaml.XML</DocumentationFile>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Compile Include="..\..\Shared\SharedAssemblyInfo.cs"> <Compile Include="..\..\Shared\SharedAssemblyInfo.cs">
@ -39,6 +40,7 @@
</Compile> </Compile>
<Compile Include="Converters\ThicknessConverter.cs" /> <Compile Include="Converters\ThicknessConverter.cs" />
<Compile Include="Context\PerspexWiringContext.cs" /> <Compile Include="Context\PerspexWiringContext.cs" />
<Compile Include="GlobalSuppressions.cs" />
<Compile Include="MarkupExtensions\BindingExtension.cs" /> <Compile Include="MarkupExtensions\BindingExtension.cs" />
<Compile Include="Converters\BrushConverter.cs" /> <Compile Include="Converters\BrushConverter.cs" />
<Compile Include="Converters\BitmapConverter.cs" /> <Compile Include="Converters\BitmapConverter.cs" />
@ -152,6 +154,9 @@
<Private>True</Private> <Private>True</Private>
</Reference> </Reference>
</ItemGroup> </ItemGroup>
<ItemGroup>
<Analyzer Include="..\..\..\packages\StyleCop.Analyzers.1.0.0-beta008\analyzers\dotnet\cs\StyleCop.Analyzers.dll" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" /> <Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets. Other similar extension points exist, see Microsoft.Common.targets.

37
src/Markup/Perspex.Markup.Xaml/PerspexXamlLoader.cs

@ -1,6 +1,6 @@
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// <copyright file="PerspexXamlLoader.cs" company="Steven Kirk"> // <copyright file="PerspexXamlLoader.cs" company="Steven Kirk">
// Copyright 2014 MIT Licence. See licence.md for more information. // Copyright 2015 MIT Licence. See licence.md for more information.
// </copyright> // </copyright>
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
@ -13,29 +13,59 @@ namespace Perspex.Markup.Xaml
using Platform; using Platform;
using Splat; using Splat;
/// <summary>
/// Loads XAML for a perspex application.
/// </summary>
public class PerspexXamlLoader : XamlLoader public class PerspexXamlLoader : XamlLoader
{ {
/// <summary>
/// Initializes a new instance of the <see cref="PerspexXamlLoader"/> class.
/// </summary>
public PerspexXamlLoader() public PerspexXamlLoader()
: this(new PerspexParserFactory()) : this(new PerspexParserFactory())
{ {
} }
/// <summary>
/// Initializes a new instance of the <see cref="PerspexXamlLoader"/> class.
/// </summary>
/// <param name="xamlParserFactory">The parser factory to use.</param>
public PerspexXamlLoader(IXamlParserFactory xamlParserFactory) public PerspexXamlLoader(IXamlParserFactory xamlParserFactory)
: base(xamlParserFactory) : base(xamlParserFactory)
{ {
} }
/// <summary>
/// Loads the XAML into a Perspex component.
/// </summary>
/// <param name="obj">The object to load the XAML into.</param>
public static void Load(object obj) public static void Load(object obj)
{ {
var loader = new PerspexXamlLoader(); var loader = new PerspexXamlLoader();
loader.Load(obj.GetType(), obj); loader.Load(obj.GetType(), obj);
} }
/// <summary>
/// Loads the XAML for a type.
/// </summary>
/// <param name="type">The type.</param>
/// <param name="rootInstance">
/// The optional instance into which the XAML should be loaded.
/// </param>
/// <returns>The loaded object.</returns>
public object Load(Type type, object rootInstance = null) public object Load(Type type, object rootInstance = null)
{ {
return this.Load(GetUriFor(type), rootInstance); return this.Load(GetUriFor(type), rootInstance);
} }
/// <summary>
/// Loads XAML from a URI.
/// </summary>
/// <param name="uri">The URI of the XAML file.</param>
/// <param name="rootInstance">
/// The optional instance into which the XAML should be loaded.
/// </param>
/// <returns>The loaded object.</returns>
public object Load(Uri uri, object rootInstance = null) public object Load(Uri uri, object rootInstance = null)
{ {
var assetLocator = Locator.Current.GetService<IAssetLoader>(); var assetLocator = Locator.Current.GetService<IAssetLoader>();
@ -52,6 +82,11 @@ namespace Perspex.Markup.Xaml
} }
} }
/// <summary>
/// Gets the URI for a type.
/// </summary>
/// <param name="type">The type.</param>
/// <returns>The URI.</returns>
private static Uri GetUriFor(Type type) private static Uri GetUriFor(Type type)
{ {
if (type.Namespace != null) if (type.Namespace != null)

1
src/Markup/Perspex.Markup.Xaml/packages.config

@ -13,4 +13,5 @@
<package id="Splat" version="1.6.2" targetFramework="portable46-net451+win81" /> <package id="Splat" version="1.6.2" targetFramework="portable46-net451+win81" />
<package id="Sprache" version="2.0.0.46" targetFramework="portable46-net451+win81" /> <package id="Sprache" version="2.0.0.46" targetFramework="portable46-net451+win81" />
<package id="Sprache.SuperJMN" version="2.0.0.46" targetFramework="portable46-net451+win81" /> <package id="Sprache.SuperJMN" version="2.0.0.46" targetFramework="portable46-net451+win81" />
<package id="StyleCop.Analyzers" version="1.0.0-beta008" targetFramework="portable46-net451+win81" developmentDependency="true" />
</packages> </packages>
Loading…
Cancel
Save