Fixing progress report

This commit is contained in:
Rikki Tooley 2014-11-08 15:34:46 +00:00
parent 7f102820da
commit 12e0b3ac62
12 changed files with 797 additions and 45 deletions

View File

@ -1,2 +1,3 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> <wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/CodeInspection/CodeAnnotations/NamespacesWithAnnotations/=IF_002ELastfm_002EDemo_002EApollo_002EAnnotations/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary> <s:Boolean x:Key="/Default/CodeInspection/CodeAnnotations/NamespacesWithAnnotations/=IF_002ELastfm_002EDemo_002EApollo_002EAnnotations/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/CodeAnnotations/NamespacesWithAnnotations/=IF_002ELastfm_002ESyro_002EAnnotations/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

View File

@ -1,4 +1,4 @@
# Api Progress ![Progress](http://progressed.io/bar/20) # Api Progress ![Progress](http://progressed.io/bar/21)
These are all the Last.fm API methods currently available. These are all the Last.fm API methods currently available.
@ -6,7 +6,7 @@ These are all the Last.fm API methods currently available.
- Methods ~~marked with strikethrough~~ aren't currently implemented. Pull requests are welcome! - Methods ~~marked with strikethrough~~ aren't currently implemented. Pull requests are welcome!
- Methods _marked with an asterisk *_ aren't listed on [the Last.fm documentation](http://www.last.fm/api), so they might not work! - Methods _marked with an asterisk *_ aren't listed on [the Last.fm documentation](http://www.last.fm/api), so they might not work!
This list is generated by the [ProgressReport](https://github.com/inflatablefriends/lastfm/tree/master/src/IF.Lastfm.ProgressReport) tool in the solution. Last updated on 26 October 2014 14:45 This list is generated by the [ProgressReport](https://github.com/inflatablefriends/lastfm/tree/master/src/IF.Lastfm.ProgressReport) tool in the solution. Last updated on 08 November 2014 15:33
## Album ## Album
- [album.getInfo](http://www.last.fm/api/show/album.getInfo) - [album.getInfo](http://www.last.fm/api/show/album.getInfo)
@ -158,6 +158,7 @@ This list is generated by the [ProgressReport](https://github.com/inflatablefrie
- [user.getInfo](http://www.last.fm/api/show/user.getInfo) - [user.getInfo](http://www.last.fm/api/show/user.getInfo)
- [user.getRecentStations](http://www.last.fm/api/show/user.getRecentStations) - [user.getRecentStations](http://www.last.fm/api/show/user.getRecentStations)
- [user.getRecentTracks](http://www.last.fm/api/show/user.getRecentTracks) - [user.getRecentTracks](http://www.last.fm/api/show/user.getRecentTracks)
- [user.getRecommendedArtists](http://www.last.fm/api/show/user.getRecommendedArtists)
- [user.getShouts](http://www.last.fm/api/show/user.getShouts) - [user.getShouts](http://www.last.fm/api/show/user.getShouts)
- [user.getTopAlbums](http://www.last.fm/api/show/user.getTopAlbums) - [user.getTopAlbums](http://www.last.fm/api/show/user.getTopAlbums)
- [user.shout](http://www.last.fm/api/show/user.shout) - [user.shout](http://www.last.fm/api/show/user.shout)
@ -171,7 +172,6 @@ This list is generated by the [ProgressReport](https://github.com/inflatablefrie
- ~~[user.getPastEvents](http://www.last.fm/api/show/user.getPastEvents)~~ - ~~[user.getPastEvents](http://www.last.fm/api/show/user.getPastEvents)~~
- ~~[user.getPersonalTags](http://www.last.fm/api/show/user.getPersonalTags)~~ - ~~[user.getPersonalTags](http://www.last.fm/api/show/user.getPersonalTags)~~
- ~~[user.getPlaylists](http://www.last.fm/api/show/user.getPlaylists)~~ - ~~[user.getPlaylists](http://www.last.fm/api/show/user.getPlaylists)~~
- ~~[user.getRecommendedArtists](http://www.last.fm/api/show/user.getRecommendedArtists)~~
- ~~[user.getRecommendedEvents](http://www.last.fm/api/show/user.getRecommendedEvents)~~ - ~~[user.getRecommendedEvents](http://www.last.fm/api/show/user.getRecommendedEvents)~~
- ~~[user.getTopArtists](http://www.last.fm/api/show/user.getTopArtists)~~ - ~~[user.getTopArtists](http://www.last.fm/api/show/user.getTopArtists)~~
- ~~[user.getTopTags](http://www.last.fm/api/show/user.getTopTags)~~ - ~~[user.getTopTags](http://www.last.fm/api/show/user.getTopTags)~~

View File

@ -1,7 +1,8 @@
<Application x:Class="IF.Lastfm.Syro.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" <Application x:Class="IF.Lastfm.Syro.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" StartupUri="MainWindow.xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" StartupUri="MainWindow.xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" d1p1:Ignorable="d" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" d1p1:Ignorable="d"
xmlns:d1p1="http://schemas.openxmlformats.org/markup-compatibility/2006"> xmlns:d1p1="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:resources="clr-namespace:IF.Lastfm.Syro.Resources">
<Application.Resources> <Application.Resources>
<ResourceDictionary> <ResourceDictionary>
<ResourceDictionary.MergedDictionaries> <ResourceDictionary.MergedDictionaries>
@ -37,6 +38,7 @@
<Setter Property="FontFamily" Value="{StaticResource ContentFontFamily}"/> <Setter Property="FontFamily" Value="{StaticResource ContentFontFamily}"/>
</Style> </Style>
<resources:BoolFlipConverter x:Key="BoolFlipConverter"/>
</ResourceDictionary> </ResourceDictionary>
</Application.Resources> </Application.Resources>

View File

@ -88,8 +88,11 @@
</ApplicationDefinition> </ApplicationDefinition>
<Compile Include="Helpers\AsyncDelegateCommand.cs" /> <Compile Include="Helpers\AsyncDelegateCommand.cs" />
<Compile Include="Helpers\DelegateCommand.cs" /> <Compile Include="Helpers\DelegateCommand.cs" />
<Compile Include="Properties\Annotations.cs" />
<Compile Include="Resources\BoolFlipConverter.cs" />
<Compile Include="Tools\Program.cs" /> <Compile Include="Tools\Program.cs" />
<Compile Include="ViewModels\MainViewModel.cs" /> <Compile Include="ViewModels\MainViewModel.cs" />
<Compile Include="ViewModels\ViewModelBase.cs" />
<Compile Include="ViewModels\ViewModelLocator.cs" /> <Compile Include="ViewModels\ViewModelLocator.cs" />
<Page Include="MainWindow.xaml"> <Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
@ -174,7 +177,6 @@
<Error Condition="!Exists('..\..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" Text="This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=317567." HelpKeyword="BCLBUILD2001" /> <Error Condition="!Exists('..\..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" Text="This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=317567." HelpKeyword="BCLBUILD2001" />
<Error Condition="Exists('..\..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" Text="The build restored NuGet packages. Build the project again to include these packages in the build. For more information, see http://go.microsoft.com/fwlink/?LinkID=317568." HelpKeyword="BCLBUILD2002" /> <Error Condition="Exists('..\..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" Text="The build restored NuGet packages. Build the project again to include these packages in the build. For more information, see http://go.microsoft.com/fwlink/?LinkID=317568." HelpKeyword="BCLBUILD2002" />
</Target> </Target>
<Import Project="$(XamlSpyInstallPath)MSBuild\FirstFloor.XamlSpy.WPF.targets" Condition="'$(XamlSpyInstallPath)' != '' and '$(Configuration)' == 'Debug'" />
<!-- 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.
<Target Name="BeforeBuild"> <Target Name="BeforeBuild">

View File

@ -4,7 +4,7 @@
xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls" xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls"
Height="350" Height="350"
MinHeight="300" MinHeight="300"
MinWidth="200" MinWidth="400"
Width="525" Width="525"
Foreground="#111111" Foreground="#111111"
WindowTitleBrush="{StaticResource SyroWindowTitleBrush}" WindowTitleBrush="{StaticResource SyroWindowTitleBrush}"

View File

@ -2,15 +2,12 @@
x:Class="IF.Lastfm.Syro.Pages.MainPage" x:Class="IF.Lastfm.Syro.Pages.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:IF.Lastfm.Dev.Syro.Pages"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls" xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls"
mc:Ignorable="d" mc:Ignorable="d"
d:DataContext="{Binding Source=MainViewModel}"> d:DataContext="{Binding Source=MainViewModel}">
<Grid> <Grid>
<TabControl Style="{StaticResource SyroTabControlStyle}"> <TabControl Style="{StaticResource SyroTabControlStyle}">
<TabItem Header="Request Builder"> <TabItem Header="Request Builder">
@ -23,14 +20,28 @@
</TabItem> </TabItem>
<TabItem Header="Progress Report"> <TabItem Header="Progress Report">
<Border Padding="28,10"> <Border Padding="28,10">
<Grid> <StackPanel>
<Button VerticalAlignment="Center" <TextBlock Style="{StaticResource SyroNormalFontStyle}"
HorizontalAlignment="Center" Text="Solution Directory"
Command="{Binding GenerateProgressReportCommand}"> Margin="0,0,0,10"/>
<TextBox Text="{Binding SolutionDir, Mode=TwoWay}"
Margin="0,0,0,15"/>
<StackPanel Orientation="Horizontal"
Margin="0,0,0,15">
<Button Command="{Binding GenerateProgressReportCommand}"
IsEnabled="{Binding GeneratingProgressReport, Converter={StaticResource BoolFlipConverter}}"
Margin="0,0,10,0">
<TextBlock Style="{StaticResource SyroNormalFontStyle}" <TextBlock Style="{StaticResource SyroNormalFontStyle}"
Margin="10,5">Generate report</TextBlock> Margin="10,5">Generate report</TextBlock>
</Button> </Button>
</Grid> <controls:ProgressRing IsActive="{Binding GeneratingProgressReport}"
Width="30"
Height="30"/>
</StackPanel>
<TextBlock Style="{StaticResource SyroNormalFontStyle}">
<Run Text="{Binding ApiProgress}"/>% complete, <Run Text="{Binding RemainingCommands.Count, Mode=OneWay}"/> commands left
</TextBlock>
</StackPanel>
</Border> </Border>
</TabItem> </TabItem>
</TabControl> </TabControl>

View File

@ -0,0 +1,614 @@
using System;
#pragma warning disable 1591
// ReSharper disable UnusedMember.Global
// ReSharper disable UnusedParameter.Local
// ReSharper disable MemberCanBePrivate.Global
// ReSharper disable UnusedAutoPropertyAccessor.Global
// ReSharper disable IntroduceOptionalParameters.Global
// ReSharper disable MemberCanBeProtected.Global
// ReSharper disable InconsistentNaming
namespace IF.Lastfm.Syro.Annotations
{
/// <summary>
/// Indicates that the value of the marked element could be <c>null</c> sometimes,
/// so the check for <c>null</c> is necessary before its usage
/// </summary>
/// <example><code>
/// [CanBeNull] public object Test() { return null; }
/// public void UseTest() {
/// var p = Test();
/// var s = p.ToString(); // Warning: Possible 'System.NullReferenceException'
/// }
/// </code></example>
[AttributeUsage(
AttributeTargets.Method | AttributeTargets.Parameter |
AttributeTargets.Property | AttributeTargets.Delegate |
AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
public sealed class CanBeNullAttribute : Attribute { }
/// <summary>
/// Indicates that the value of the marked element could never be <c>null</c>
/// </summary>
/// <example><code>
/// [NotNull] public object Foo() {
/// return null; // Warning: Possible 'null' assignment
/// }
/// </code></example>
[AttributeUsage(
AttributeTargets.Method | AttributeTargets.Parameter |
AttributeTargets.Property | AttributeTargets.Delegate |
AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
public sealed class NotNullAttribute : Attribute { }
/// <summary>
/// Indicates that the marked method builds string by format pattern and (optional) arguments.
/// Parameter, which contains format string, should be given in constructor. The format string
/// should be in <see cref="string.Format(IFormatProvider,string,object[])"/>-like form
/// </summary>
/// <example><code>
/// [StringFormatMethod("message")]
/// public void ShowError(string message, params object[] args) { /* do something */ }
/// public void Foo() {
/// ShowError("Failed: {0}"); // Warning: Non-existing argument in format string
/// }
/// </code></example>
[AttributeUsage(
AttributeTargets.Constructor | AttributeTargets.Method,
AllowMultiple = false, Inherited = true)]
public sealed class StringFormatMethodAttribute : Attribute
{
/// <param name="formatParameterName">
/// Specifies which parameter of an annotated method should be treated as format-string
/// </param>
public StringFormatMethodAttribute(string formatParameterName)
{
FormatParameterName = formatParameterName;
}
public string FormatParameterName { get; private set; }
}
/// <summary>
/// Indicates that the function argument should be string literal and match one
/// of the parameters of the caller function. For example, ReSharper annotates
/// the parameter of <see cref="System.ArgumentNullException"/>
/// </summary>
/// <example><code>
/// public void Foo(string param) {
/// if (param == null)
/// throw new ArgumentNullException("par"); // Warning: Cannot resolve symbol
/// }
/// </code></example>
[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = true)]
public sealed class InvokerParameterNameAttribute : Attribute { }
/// <summary>
/// Indicates that the method is contained in a type that implements
/// <see cref="System.ComponentModel.INotifyPropertyChanged"/> interface
/// and this method is used to notify that some property value changed
/// </summary>
/// <remarks>
/// The method should be non-static and conform to one of the supported signatures:
/// <list>
/// <item><c>NotifyChanged(string)</c></item>
/// <item><c>NotifyChanged(params string[])</c></item>
/// <item><c>NotifyChanged{T}(Expression{Func{T}})</c></item>
/// <item><c>NotifyChanged{T,U}(Expression{Func{T,U}})</c></item>
/// <item><c>SetProperty{T}(ref T, T, string)</c></item>
/// </list>
/// </remarks>
/// <example><code>
/// public class Foo : INotifyPropertyChanged {
/// public event PropertyChangedEventHandler PropertyChanged;
/// [NotifyPropertyChangedInvocator]
/// protected virtual void NotifyChanged(string propertyName) { ... }
///
/// private string _name;
/// public string Name {
/// get { return _name; }
/// set { _name = value; NotifyChanged("LastName"); /* Warning */ }
/// }
/// }
/// </code>
/// Examples of generated notifications:
/// <list>
/// <item><c>NotifyChanged("Property")</c></item>
/// <item><c>NotifyChanged(() =&gt; Property)</c></item>
/// <item><c>NotifyChanged((VM x) =&gt; x.Property)</c></item>
/// <item><c>SetProperty(ref myField, value, "Property")</c></item>
/// </list>
/// </example>
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = true)]
public sealed class NotifyPropertyChangedInvocatorAttribute : Attribute
{
public NotifyPropertyChangedInvocatorAttribute() { }
public NotifyPropertyChangedInvocatorAttribute(string parameterName)
{
ParameterName = parameterName;
}
public string ParameterName { get; private set; }
}
/// <summary>
/// Describes dependency between method input and output
/// </summary>
/// <syntax>
/// <p>Function Definition Table syntax:</p>
/// <list>
/// <item>FDT ::= FDTRow [;FDTRow]*</item>
/// <item>FDTRow ::= Input =&gt; Output | Output &lt;= Input</item>
/// <item>Input ::= ParameterName: Value [, Input]*</item>
/// <item>Output ::= [ParameterName: Value]* {halt|stop|void|nothing|Value}</item>
/// <item>Value ::= true | false | null | notnull | canbenull</item>
/// </list>
/// If method has single input parameter, it's name could be omitted.<br/>
/// Using <c>halt</c> (or <c>void</c>/<c>nothing</c>, which is the same)
/// for method output means that the methos doesn't return normally.<br/>
/// <c>canbenull</c> annotation is only applicable for output parameters.<br/>
/// You can use multiple <c>[ContractAnnotation]</c> for each FDT row,
/// or use single attribute with rows separated by semicolon.<br/>
/// </syntax>
/// <examples><list>
/// <item><code>
/// [ContractAnnotation("=> halt")]
/// public void TerminationMethod()
/// </code></item>
/// <item><code>
/// [ContractAnnotation("halt &lt;= condition: false")]
/// public void Assert(bool condition, string text) // regular assertion method
/// </code></item>
/// <item><code>
/// [ContractAnnotation("s:null => true")]
/// public bool IsNullOrEmpty(string s) // string.IsNullOrEmpty()
/// </code></item>
/// <item><code>
/// // A method that returns null if the parameter is null, and not null if the parameter is not null
/// [ContractAnnotation("null => null; notnull => notnull")]
/// public object Transform(object data)
/// </code></item>
/// <item><code>
/// [ContractAnnotation("s:null=>false; =>true,result:notnull; =>false, result:null")]
/// public bool TryParse(string s, out Person result)
/// </code></item>
/// </list></examples>
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true, Inherited = true)]
public sealed class ContractAnnotationAttribute : Attribute
{
public ContractAnnotationAttribute([NotNull] string contract)
: this(contract, false) { }
public ContractAnnotationAttribute([NotNull] string contract, bool forceFullStates)
{
Contract = contract;
ForceFullStates = forceFullStates;
}
public string Contract { get; private set; }
public bool ForceFullStates { get; private set; }
}
/// <summary>
/// Indicates that marked element should be localized or not
/// </summary>
/// <example><code>
/// [LocalizationRequiredAttribute(true)]
/// public class Foo {
/// private string str = "my string"; // Warning: Localizable string
/// }
/// </code></example>
[AttributeUsage(AttributeTargets.All, AllowMultiple = false, Inherited = true)]
public sealed class LocalizationRequiredAttribute : Attribute
{
public LocalizationRequiredAttribute() : this(true) { }
public LocalizationRequiredAttribute(bool required)
{
Required = required;
}
public bool Required { get; private set; }
}
/// <summary>
/// Indicates that the value of the marked type (or its derivatives)
/// cannot be compared using '==' or '!=' operators and <c>Equals()</c>
/// should be used instead. However, using '==' or '!=' for comparison
/// with <c>null</c> is always permitted.
/// </summary>
/// <example><code>
/// [CannotApplyEqualityOperator]
/// class NoEquality { }
/// class UsesNoEquality {
/// public void Test() {
/// var ca1 = new NoEquality();
/// var ca2 = new NoEquality();
/// if (ca1 != null) { // OK
/// bool condition = ca1 == ca2; // Warning
/// }
/// }
/// }
/// </code></example>
[AttributeUsage(
AttributeTargets.Interface | AttributeTargets.Class |
AttributeTargets.Struct, AllowMultiple = false, Inherited = true)]
public sealed class CannotApplyEqualityOperatorAttribute : Attribute { }
/// <summary>
/// When applied to a target attribute, specifies a requirement for any type marked
/// with the target attribute to implement or inherit specific type or types.
/// </summary>
/// <example><code>
/// [BaseTypeRequired(typeof(IComponent)] // Specify requirement
/// public class ComponentAttribute : Attribute { }
/// [Component] // ComponentAttribute requires implementing IComponent interface
/// public class MyComponent : IComponent { }
/// </code></example>
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = true)]
[BaseTypeRequired(typeof(Attribute))]
public sealed class BaseTypeRequiredAttribute : Attribute
{
public BaseTypeRequiredAttribute([NotNull] Type baseType)
{
BaseType = baseType;
}
[NotNull] public Type BaseType { get; private set; }
}
/// <summary>
/// Indicates that the marked symbol is used implicitly
/// (e.g. via reflection, in external library), so this symbol
/// will not be marked as unused (as well as by other usage inspections)
/// </summary>
[AttributeUsage(AttributeTargets.All, AllowMultiple = false, Inherited = true)]
public sealed class UsedImplicitlyAttribute : Attribute
{
public UsedImplicitlyAttribute()
: this(ImplicitUseKindFlags.Default, ImplicitUseTargetFlags.Default) { }
public UsedImplicitlyAttribute(ImplicitUseKindFlags useKindFlags)
: this(useKindFlags, ImplicitUseTargetFlags.Default) { }
public UsedImplicitlyAttribute(ImplicitUseTargetFlags targetFlags)
: this(ImplicitUseKindFlags.Default, targetFlags) { }
public UsedImplicitlyAttribute(
ImplicitUseKindFlags useKindFlags, ImplicitUseTargetFlags targetFlags)
{
UseKindFlags = useKindFlags;
TargetFlags = targetFlags;
}
public ImplicitUseKindFlags UseKindFlags { get; private set; }
public ImplicitUseTargetFlags TargetFlags { get; private set; }
}
/// <summary>
/// Should be used on attributes and causes ReSharper
/// to not mark symbols marked with such attributes as unused
/// (as well as by other usage inspections)
/// </summary>
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = true)]
public sealed class MeansImplicitUseAttribute : Attribute
{
public MeansImplicitUseAttribute()
: this(ImplicitUseKindFlags.Default, ImplicitUseTargetFlags.Default) { }
public MeansImplicitUseAttribute(ImplicitUseKindFlags useKindFlags)
: this(useKindFlags, ImplicitUseTargetFlags.Default) { }
public MeansImplicitUseAttribute(ImplicitUseTargetFlags targetFlags)
: this(ImplicitUseKindFlags.Default, targetFlags) { }
public MeansImplicitUseAttribute(
ImplicitUseKindFlags useKindFlags, ImplicitUseTargetFlags targetFlags)
{
UseKindFlags = useKindFlags;
TargetFlags = targetFlags;
}
[UsedImplicitly] public ImplicitUseKindFlags UseKindFlags { get; private set; }
[UsedImplicitly] public ImplicitUseTargetFlags TargetFlags { get; private set; }
}
[Flags]
public enum ImplicitUseKindFlags
{
Default = Access | Assign | InstantiatedWithFixedConstructorSignature,
/// <summary>Only entity marked with attribute considered used</summary>
Access = 1,
/// <summary>Indicates implicit assignment to a member</summary>
Assign = 2,
/// <summary>
/// Indicates implicit instantiation of a type with fixed constructor signature.
/// That means any unused constructor parameters won't be reported as such.
/// </summary>
InstantiatedWithFixedConstructorSignature = 4,
/// <summary>Indicates implicit instantiation of a type</summary>
InstantiatedNoFixedConstructorSignature = 8,
}
/// <summary>
/// Specify what is considered used implicitly
/// when marked with <see cref="MeansImplicitUseAttribute"/>
/// or <see cref="UsedImplicitlyAttribute"/>
/// </summary>
[Flags]
public enum ImplicitUseTargetFlags
{
Default = Itself,
Itself = 1,
/// <summary>Members of entity marked with attribute are considered used</summary>
Members = 2,
/// <summary>Entity marked with attribute and all its members considered used</summary>
WithMembers = Itself | Members
}
/// <summary>
/// This attribute is intended to mark publicly available API
/// which should not be removed and so is treated as used
/// </summary>
[MeansImplicitUse]
public sealed class PublicAPIAttribute : Attribute
{
public PublicAPIAttribute() { }
public PublicAPIAttribute([NotNull] string comment)
{
Comment = comment;
}
[NotNull] public string Comment { get; private set; }
}
/// <summary>
/// Tells code analysis engine if the parameter is completely handled
/// when the invoked method is on stack. If the parameter is a delegate,
/// indicates that delegate is executed while the method is executed.
/// If the parameter is an enumerable, indicates that it is enumerated
/// while the method is executed
/// </summary>
[AttributeUsage(AttributeTargets.Parameter, Inherited = true)]
public sealed class InstantHandleAttribute : Attribute { }
/// <summary>
/// Indicates that a method does not make any observable state changes.
/// The same as <c>System.Diagnostics.Contracts.PureAttribute</c>
/// </summary>
/// <example><code>
/// [Pure] private int Multiply(int x, int y) { return x * y; }
/// public void Foo() {
/// const int a = 2, b = 2;
/// Multiply(a, b); // Waring: Return value of pure method is not used
/// }
/// </code></example>
[AttributeUsage(AttributeTargets.Method, Inherited = true)]
public sealed class PureAttribute : Attribute { }
/// <summary>
/// Indicates that a parameter is a path to a file or a folder
/// within a web project. Path can be relative or absolute,
/// starting from web root (~)
/// </summary>
[AttributeUsage(AttributeTargets.Parameter)]
public class PathReferenceAttribute : Attribute
{
public PathReferenceAttribute() { }
public PathReferenceAttribute([PathReference] string basePath)
{
BasePath = basePath;
}
[NotNull] public string BasePath { get; private set; }
}
// ASP.NET MVC attributes
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
public sealed class AspMvcAreaMasterLocationFormatAttribute : Attribute
{
public AspMvcAreaMasterLocationFormatAttribute(string format) { }
}
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
public sealed class AspMvcAreaPartialViewLocationFormatAttribute : Attribute
{
public AspMvcAreaPartialViewLocationFormatAttribute(string format) { }
}
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
public sealed class AspMvcAreaViewLocationFormatAttribute : Attribute
{
public AspMvcAreaViewLocationFormatAttribute(string format) { }
}
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
public sealed class AspMvcMasterLocationFormatAttribute : Attribute
{
public AspMvcMasterLocationFormatAttribute(string format) { }
}
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
public sealed class AspMvcPartialViewLocationFormatAttribute : Attribute
{
public AspMvcPartialViewLocationFormatAttribute(string format) { }
}
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
public sealed class AspMvcViewLocationFormatAttribute : Attribute
{
public AspMvcViewLocationFormatAttribute(string format) { }
}
/// <summary>
/// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter
/// is an MVC action. If applied to a method, the MVC action name is calculated
/// implicitly from the context. Use this attribute for custom wrappers similar to
/// <c>System.Web.Mvc.Html.ChildActionExtensions.RenderAction(HtmlHelper, String)</c>
/// </summary>
[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)]
public sealed class AspMvcActionAttribute : Attribute
{
public AspMvcActionAttribute() { }
public AspMvcActionAttribute([NotNull] string anonymousProperty)
{
AnonymousProperty = anonymousProperty;
}
[NotNull] public string AnonymousProperty { get; private set; }
}
/// <summary>
/// ASP.NET MVC attribute. Indicates that a parameter is an MVC area.
/// Use this attribute for custom wrappers similar to
/// <c>System.Web.Mvc.Html.ChildActionExtensions.RenderAction(HtmlHelper, String)</c>
/// </summary>
[AttributeUsage(AttributeTargets.Parameter)]
public sealed class AspMvcAreaAttribute : PathReferenceAttribute
{
public AspMvcAreaAttribute() { }
public AspMvcAreaAttribute([NotNull] string anonymousProperty)
{
AnonymousProperty = anonymousProperty;
}
[NotNull] public string AnonymousProperty { get; private set; }
}
/// <summary>
/// ASP.NET MVC attribute. If applied to a parameter, indicates that
/// the parameter is an MVC controller. If applied to a method,
/// the MVC controller name is calculated implicitly from the context.
/// Use this attribute for custom wrappers similar to
/// <c>System.Web.Mvc.Html.ChildActionExtensions.RenderAction(HtmlHelper, String, String)</c>
/// </summary>
[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)]
public sealed class AspMvcControllerAttribute : Attribute
{
public AspMvcControllerAttribute() { }
public AspMvcControllerAttribute([NotNull] string anonymousProperty)
{
AnonymousProperty = anonymousProperty;
}
[NotNull] public string AnonymousProperty { get; private set; }
}
/// <summary>
/// ASP.NET MVC attribute. Indicates that a parameter is an MVC Master.
/// Use this attribute for custom wrappers similar to
/// <c>System.Web.Mvc.Controller.View(String, String)</c>
/// </summary>
[AttributeUsage(AttributeTargets.Parameter)]
public sealed class AspMvcMasterAttribute : Attribute { }
/// <summary>
/// ASP.NET MVC attribute. Indicates that a parameter is an MVC model type.
/// Use this attribute for custom wrappers similar to
/// <c>System.Web.Mvc.Controller.View(String, Object)</c>
/// </summary>
[AttributeUsage(AttributeTargets.Parameter)]
public sealed class AspMvcModelTypeAttribute : Attribute { }
/// <summary>
/// ASP.NET MVC attribute. If applied to a parameter, indicates that
/// the parameter is an MVC partial view. If applied to a method,
/// the MVC partial view name is calculated implicitly from the context.
/// Use this attribute for custom wrappers similar to
/// <c>System.Web.Mvc.Html.RenderPartialExtensions.RenderPartial(HtmlHelper, String)</c>
/// </summary>
[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)]
public sealed class AspMvcPartialViewAttribute : PathReferenceAttribute { }
/// <summary>
/// ASP.NET MVC attribute. Allows disabling all inspections
/// for MVC views within a class or a method.
/// </summary>
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)]
public sealed class AspMvcSupressViewErrorAttribute : Attribute { }
/// <summary>
/// ASP.NET MVC attribute. Indicates that a parameter is an MVC display template.
/// Use this attribute for custom wrappers similar to
/// <c>System.Web.Mvc.Html.DisplayExtensions.DisplayForModel(HtmlHelper, String)</c>
/// </summary>
[AttributeUsage(AttributeTargets.Parameter)]
public sealed class AspMvcDisplayTemplateAttribute : Attribute { }
/// <summary>
/// ASP.NET MVC attribute. Indicates that a parameter is an MVC editor template.
/// Use this attribute for custom wrappers similar to
/// <c>System.Web.Mvc.Html.EditorExtensions.EditorForModel(HtmlHelper, String)</c>
/// </summary>
[AttributeUsage(AttributeTargets.Parameter)]
public sealed class AspMvcEditorTemplateAttribute : Attribute { }
/// <summary>
/// ASP.NET MVC attribute. Indicates that a parameter is an MVC template.
/// Use this attribute for custom wrappers similar to
/// <c>System.ComponentModel.DataAnnotations.UIHintAttribute(System.String)</c>
/// </summary>
[AttributeUsage(AttributeTargets.Parameter)]
public sealed class AspMvcTemplateAttribute : Attribute { }
/// <summary>
/// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter
/// is an MVC view. If applied to a method, the MVC view name is calculated implicitly
/// from the context. Use this attribute for custom wrappers similar to
/// <c>System.Web.Mvc.Controller.View(Object)</c>
/// </summary>
[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)]
public sealed class AspMvcViewAttribute : PathReferenceAttribute { }
/// <summary>
/// ASP.NET MVC attribute. When applied to a parameter of an attribute,
/// indicates that this parameter is an MVC action name
/// </summary>
/// <example><code>
/// [ActionName("Foo")]
/// public ActionResult Login(string returnUrl) {
/// ViewBag.ReturnUrl = Url.Action("Foo"); // OK
/// return RedirectToAction("Bar"); // Error: Cannot resolve action
/// }
/// </code></example>
[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Property)]
public sealed class AspMvcActionSelectorAttribute : Attribute { }
[AttributeUsage(
AttributeTargets.Parameter | AttributeTargets.Property |
AttributeTargets.Field, Inherited = true)]
public sealed class HtmlElementAttributesAttribute : Attribute
{
public HtmlElementAttributesAttribute() { }
public HtmlElementAttributesAttribute([NotNull] string name)
{
Name = name;
}
[NotNull] public string Name { get; private set; }
}
[AttributeUsage(
AttributeTargets.Parameter | AttributeTargets.Field |
AttributeTargets.Property, Inherited = true)]
public sealed class HtmlAttributeValueAttribute : Attribute
{
public HtmlAttributeValueAttribute([NotNull] string name)
{
Name = name;
}
[NotNull] public string Name { get; private set; }
}
// Razor attributes
/// <summary>
/// Razor attribute. Indicates that a parameter or a method is a Razor section.
/// Use this attribute for custom wrappers similar to
/// <c>System.Web.WebPages.WebPageBase.RenderSection(String)</c>
/// </summary>
[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method, Inherited = true)]
public sealed class RazorSectionAttribute : Attribute { }
}

View File

@ -0,0 +1,19 @@
using System;
using System.Globalization;
using System.Windows.Data;
namespace IF.Lastfm.Syro.Resources
{
public class BoolFlipConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return value is bool && !(bool) value;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return value is bool && !(bool)value;
}
}
}

View File

@ -5,12 +5,12 @@
<ResourceDictionary> <ResourceDictionary>
<!-- General --> <!-- General -->
<Color x:Key="SyroColour">#C0D73B</Color> <Color x:Key="SyroColour">#C0D73B</Color>
<SolidColorBrush x:Key="BackgroundHighlighted" Color="#54545C" /> <SolidColorBrush x:Key="BackgroundHighlighted" Color="#222" />
<SolidColorBrush x:Key="BorderBrushHighlighted" Color="#6A6A75" /> <SolidColorBrush x:Key="BorderBrushHighlighted" Color="#333" />
<SolidColorBrush x:Key="BackgroundSelected" Color="{StaticResource SyroColour}" /> <SolidColorBrush x:Key="BackgroundSelected" Color="{StaticResource SyroColour}" />
<SolidColorBrush x:Key="BorderBrushSelected" Color="{StaticResource SyroColour}" /> <SolidColorBrush x:Key="BorderBrushSelected" Color="{StaticResource SyroColour}" />
<SolidColorBrush x:Key="BackgroundNormal" Color="#3F3F46" /> <SolidColorBrush x:Key="BackgroundNormal" Color="#222" />
<SolidColorBrush x:Key="BorderBrushNormal" Color="#54545C" /> <SolidColorBrush x:Key="BorderBrushNormal" Color="#333" />
<!-- Close Button --> <!-- Close Button -->
<SolidColorBrush x:Key="CloseButtonBackgroundHighlighted" Color="#39ADFB" /> <SolidColorBrush x:Key="CloseButtonBackgroundHighlighted" Color="#39ADFB" />
<SolidColorBrush x:Key="CloseButtonBackgroundPressed" Color="#084E7D" /> <SolidColorBrush x:Key="CloseButtonBackgroundPressed" Color="#084E7D" />
@ -27,7 +27,7 @@
<Setter Property="Background" <Setter Property="Background"
Value="Transparent" /> Value="Transparent" />
<Setter Property="Foreground" <Setter Property="Foreground"
Value="#111" /> Value="#cccccc" />
<Setter Property="HeaderTemplate"> <Setter Property="HeaderTemplate">
<Setter.Value> <Setter.Value>
<DataTemplate> <DataTemplate>
@ -147,11 +147,15 @@
Value="true"> Value="true">
<Setter Property="Background" <Setter Property="Background"
Value="{DynamicResource BorderBrushSelected}" /> Value="{DynamicResource BorderBrushSelected}" />
<Setter Property="Foreground"
Value="{DynamicResource ForegroundSelected}"/>
</Trigger> </Trigger>
<Trigger Property="IsSelected" <Trigger Property="IsSelected"
Value="true"> Value="true">
<Setter Property="Background" <Setter Property="Background"
Value="{DynamicResource BackgroundSelected}" /> Value="{DynamicResource BackgroundSelected}" />
<Setter Property="Foreground"
Value="{DynamicResource ForegroundSelected}"/>
</Trigger> </Trigger>
</ControlTemplate.Triggers> </ControlTemplate.Triggers>
</ControlTemplate> </ControlTemplate>
@ -167,7 +171,7 @@
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="*" /> <RowDefinition Height="*" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Border Background="Transparent" <Border Background="#222"
BorderBrush="{DynamicResource BackgroundSelected}" BorderBrush="{DynamicResource BackgroundSelected}"
BorderThickness="0,0,0,1"> BorderThickness="0,0,0,1">
<TabPanel Name="HeaderPanel" <TabPanel Name="HeaderPanel"

View File

@ -48,18 +48,17 @@ internal static Dictionary<string, IEnumerable<string>> GetApiMethods()
return null; return null;
} }
var html = response.Result.Content.ReadAsStringAsync(); var htmlTask = response.Result.Content.ReadAsStringAsync();
html.Wait(); htmlTask.Wait();
var doc = new HtmlDocument(); var doc = new HtmlDocument();
doc.LoadHtml(html.Result); doc.LoadHtml(htmlTask.Result);
var wspanel = doc.DocumentNode.Descendants("//ul[@class='wspanel']").LastOrDefault(); var wspanel = doc.DocumentNode.Descendants().FirstOrDefault(d => d.GetAttributeValue("class", "").Contains("wspanel")
&& d.PreviousSibling.PreviousSibling.OuterHtml == "<h2>API Methods</h2>");
if (wspanel == null) if (wspanel == null)
{ {
Console.WriteLine("Couldn't parse HTML"); throw new FormatException(string.Format("Couldn't find wspanel in HTML {0}", htmlTask.Result));
Console.ReadLine();
return null;
} }
// each package is a section of the API // each package is a section of the API
@ -72,7 +71,7 @@ internal static Dictionary<string, IEnumerable<string>> GetApiMethods()
var ul = package.Element("ul"); var ul = package.Element("ul");
var methodLinks = ul.Descendants("child::li"); var methodLinks = ul.Elements("li");
var methods = methodLinks.Select(a => a.InnerText); var methods = methodLinks.Select(a => a.InnerText);
allMethods.Add(h3.InnerText, methods); allMethods.Add(h3.InnerText, methods);
@ -133,21 +132,20 @@ private static string GetApiMethodFromCommandType(Type type)
#region Report #region Report
internal static void WriteReport(Dictionary<string, IEnumerable<string>> apiGroup, List<string> allImplemented) internal static void WriteReport(Dictionary<string, IEnumerable<string>> apiGroup, List<string> allImplemented, string path)
{ {
var markdownBuilder = new StringBuilder(); var markdownBuilder = new StringBuilder();
var percent = (((double)allImplemented.Count)/apiGroup.SelectMany(api => api.Value).Count()) * 100; var percent = GetPercentage(apiGroup, allImplemented);
markdownBuilder.AppendFormat(_progressReportIntro, (int)Math.Floor(percent), DateTime.UtcNow.ToString("f")); markdownBuilder.AppendFormat(_progressReportIntro, (int)Math.Floor(percent), DateTime.UtcNow.ToString("f"));
foreach (var group in apiGroup.OrderBy(kv => kv.Key)) foreach (var group in apiGroup.OrderBy(kv => kv.Key))
{ {
var apiGroupName = @group.Key; var apiGroupName = group.Key;
var implemented = var implemented = allImplemented.Where(m => m.StartsWith(apiGroupName.ToLowerInvariant(), StringComparison.Ordinal)).ToList();
allImplemented.Where(m => m.StartsWith(apiGroupName.ToLowerInvariant(), StringComparison.Ordinal)).ToList();
var matches = @group.Value.Intersect(implemented).ToList(); var matches = group.Value.Intersect(implemented).ToList();
var notImplemented = @group.Value.Except(implemented).ToList(); var notImplemented = group.Value.Except(implemented).ToList();
var secret = implemented.Except(@group.Value).ToList(); var secret = implemented.Except(group.Value).ToList();
markdownBuilder.AppendFormat("## {0}\n\n", apiGroupName); markdownBuilder.AppendFormat("## {0}\n\n", apiGroupName);
foreach (var match in matches) foreach (var match in matches)
@ -168,7 +166,7 @@ internal static void WriteReport(Dictionary<string, IEnumerable<string>> apiGrou
var markdown = markdownBuilder.ToString(); var markdown = markdownBuilder.ToString();
// write to output directory // write to output directory
using (var fs = new FileStream("PROGRESS.md", FileMode.Create)) using (var fs = new FileStream(path, FileMode.Create))
{ {
using (var sw = new StreamWriter(fs)) using (var sw = new StreamWriter(fs))
{ {
@ -177,6 +175,12 @@ internal static void WriteReport(Dictionary<string, IEnumerable<string>> apiGrou
} }
} }
public static double GetPercentage(Dictionary<string, IEnumerable<string>> apiGroup, List<string> allImplemented)
{
var percent = (((double) allImplemented.Count)/apiGroup.SelectMany(api => api.Value).Count())*100;
return percent;
}
#endregion #endregion
} }
} }

View File

@ -1,4 +1,8 @@
using IF.Common.Metro.Mvvm; using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using IF.Common.Metro.Mvvm;
using IF.Lastfm.Syro.Tools; using IF.Lastfm.Syro.Tools;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -6,17 +10,76 @@
namespace IF.Lastfm.Syro.ViewModels namespace IF.Lastfm.Syro.ViewModels
{ {
internal class MainViewModel internal class MainViewModel : ViewModelBase
{ {
private string _solutionDir;
private bool _generatingProgressReport;
private List<string> _remainingCommands;
private int _apiProgress;
public bool GeneratingProgressReport
{
get { return _generatingProgressReport; }
set
{
if (value.Equals(_generatingProgressReport)) return;
_generatingProgressReport = value;
OnPropertyChanged();
}
}
public string SolutionDir
{
get { return _solutionDir; }
set
{
if (value == _solutionDir) return;
_solutionDir = value;
OnPropertyChanged();
}
}
public int ApiProgress
{
get { return _apiProgress; }
set
{
if (value.Equals(_apiProgress)) return;
_apiProgress = value;
OnPropertyChanged();
}
}
public List<string> RemainingCommands
{
get { return _remainingCommands; }
set
{
if (Equals(value, _remainingCommands)) return;
_remainingCommands = value;
OnPropertyChanged();
}
}
public ICommand GenerateProgressReportCommand { get; private set; } public ICommand GenerateProgressReportCommand { get; private set; }
public MainViewModel() public MainViewModel()
{ {
GenerateProgressReportCommand = new AsyncDelegateCommand(GenerateProgressReport); GenerateProgressReportCommand = new AsyncDelegateCommand(GenerateProgressReport);
var currentDir = System.AppDomain.CurrentDomain.BaseDirectory;
SolutionDir = Path.GetFullPath(currentDir + "../../../../"); // assuming this is running in debug dir
} }
private async Task GenerateProgressReport() private async Task GenerateProgressReport()
{ {
if (GeneratingProgressReport)
{
return;
}
GeneratingProgressReport = true;
await Task.Run(() => await Task.Run(() =>
{ {
// scrape Last.fm API documentation // scrape Last.fm API documentation
@ -30,11 +93,25 @@ await Task.Run(() =>
var allImplemented = ProgressReport.GetImplementedCommands().ToList(); var allImplemented = ProgressReport.GetImplementedCommands().ToList();
// generate the markdown // generate the markdown
ProgressReport.WriteReport(apiGroup, allImplemented); var path = Path.GetFullPath(SolutionDir + "PROGRESS.md");
ProgressReport.WriteReport(apiGroup, allImplemented, path);
// file is copied to the solution root by a post-build script. // ui, duplicating code but w/e
// TODO configure build dir in syro ApiProgress = (int)ProgressReport.GetPercentage(apiGroup, allImplemented);
var notimp = new List<string>();
foreach (var group in apiGroup)
{
var implemented = allImplemented.Where(m => m.StartsWith(group.Key.ToLowerInvariant(), StringComparison.Ordinal)).ToList();
var notImplemented = group.Value.Except(implemented).ToList();
notimp.AddRange(notImplemented);
}
RemainingCommands = notimp;
}); });
GeneratingProgressReport = false;
} }
} }
} }

View File

@ -0,0 +1,18 @@
using System.ComponentModel;
using System.Runtime.CompilerServices;
using IF.Lastfm.Syro.Annotations;
namespace IF.Lastfm.Syro.ViewModels
{
internal class ViewModelBase : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
[NotifyPropertyChangedInvocator]
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
PropertyChangedEventHandler handler = PropertyChanged;
if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
}
}
}