├── .gitattributes
├── .gitignore
├── AppVeyor.Api.Tests
├── AppVeyor.Api.Tests.csproj
├── ProjectApiTest.cs
├── Properties
│ └── AssemblyInfo.cs
└── packages.config
├── AppVeyor.Api
├── AppVeyor.Api.csproj
├── AppVeyorService.cs
├── AppVeyorServiceResponse.cs
├── IAppVeyorService.cs
├── ProjectApi.cs
├── Properties
│ └── AssemblyInfo.cs
├── Resource.cs
└── packages.config
├── AppVeyor.Common
├── AppVeyor.Common.csproj
├── Aspects
│ └── TrackUsage.cs
├── AsyncManualResetEvent.cs
├── BuildStatus.cs
├── Entities
│ ├── AccessRight.cs
│ ├── AccessRightDefinition.cs
│ ├── Build.cs
│ ├── BuildInfo.cs
│ ├── Job.cs
│ ├── NuGetFeed.cs
│ ├── Project.cs
│ ├── ProjectHistory.cs
│ ├── RoleAce.cs
│ └── SecurityDescriptor.cs
├── Exceptions
│ ├── AppVeyorException.cs
│ └── AppVeyorUnauthorizedException.cs
├── Extensions
│ ├── DateTimeExtensions.cs
│ ├── EnumerableExtensions.cs
│ ├── ProjectExtensions.cs
│ ├── ServiceProviderExtensions.cs
│ └── StringExtensions.cs
├── Properties
│ └── AssemblyInfo.cs
├── Telemetry.cs
└── packages.config
├── AppVeyor.Package
├── AppVeyor.Package.cs
├── AppVeyor.Package.csproj
├── AppVeyor.Package.vsct
├── AppVeyorPackage.cs
├── CommandSet.cs
├── Commands
│ ├── Base
│ │ └── DynamicCommand.cs
│ ├── ContextChangedCommand.cs
│ ├── RefreshCommand.cs
│ ├── ShowAppVeyorWindowCommand.cs
│ └── ShowOptionsCommand.cs
├── GlobalSuppressions.cs
├── Key.snk
├── PkgCmdID.cs
├── Properties
│ └── AssemblyInfo.cs
├── Resources.Designer.cs
├── Resources.resx
├── Resources
│ ├── AppVeyorToolbar.png
│ ├── Images.png
│ └── Package.ico
├── VSPackage.resx
├── packages.config
└── source.extension.vsixmanifest
├── AppVeyor.UI
├── AppVeyor.UI.csproj
├── Aspects
│ └── HandleException.cs
├── BindinError
│ └── BindingTraceListener.cs
├── Common
│ ├── Constants.cs
│ ├── DataContextSpy.cs
│ ├── DropDownButton.cs
│ ├── Message.cs
│ ├── PauseToken.cs
│ ├── PauseTokenSource.cs
│ ├── ProjectComparer.cs
│ ├── RelayCommand.cs
│ ├── SearchTask.cs
│ └── VsShellHelper.cs
├── Controls
│ └── ClosableTab
│ │ ├── ClosableHeader.xaml
│ │ ├── ClosableHeader.xaml.cs
│ │ └── ClosableTab.cs
├── Converters
│ ├── Base
│ │ └── BaseConverter.cs
│ ├── BoolToVisibilityConverter.cs
│ ├── BuildStatusToTooltipConverter.cs
│ ├── ButtonForegroundColorConverter.cs
│ ├── DebuggingConverter.cs
│ ├── ErrorsToMessageVisibilityConverter.cs
│ ├── ErrorsToVisibilityConverter.cs
│ ├── MessagesHeaderConverter.cs
│ ├── ProjectBuildStatusToColorConverter.cs
│ ├── ProjectBuildStatusToTextConverter.cs
│ ├── ProjectBuildStatusToVisibilityConverter.cs
│ ├── ProjectToBranchConverter.cs
│ ├── ProjectToBuildMessageConverter.cs
│ ├── ProjectToBuildVersionConverter.cs
│ ├── ProjectToCommitNumberConverter.cs
│ ├── ProjectToCommittedByConverter.cs
│ ├── ProjectToCommittedDateConverter.cs
│ └── ProjectToLastRunConverter.cs
├── Images
│ └── ApiToken.png
├── Key.snk
├── Model
│ └── Repository.cs
├── Options
│ ├── AppVeyorOptions.Designer.cs
│ ├── AppVeyorOptions.cs
│ └── OptionsChangedEventArgs.cs
├── Properties
│ └── AssemblyInfo.cs
├── Resources
│ ├── branch-2x.png
│ ├── build.png
│ ├── cancel.png
│ ├── commit-2x.png
│ ├── more.png
│ └── play.png
├── Services
│ ├── CommandManagerServiceService.cs
│ ├── EventManagerService.cs
│ ├── ICommandManagerService.cs
│ └── IEventManager.cs
├── ToolWindows
│ ├── AppVeyorWindow.cs
│ ├── AppVeyorWindowContent.xaml
│ └── AppVeyorWindowContent.xaml.cs
├── ViewModel
│ ├── AppVeyorWindowViewModel.cs
│ └── Base
│ │ └── ViewModelBase.cs
└── packages.config
├── AppVeyorExtension.sln
├── README.md
└── _Screenshots
└── appveyor_toolwindow_full_annotate.jpg
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
4 | # Custom for Visual Studio
5 | *.cs diff=csharp
6 |
7 | # Standard to msysgit
8 | *.doc diff=astextplain
9 | *.DOC diff=astextplain
10 | *.docx diff=astextplain
11 | *.DOCX diff=astextplain
12 | *.dot diff=astextplain
13 | *.DOT diff=astextplain
14 | *.pdf diff=astextplain
15 | *.PDF diff=astextplain
16 | *.rtf diff=astextplain
17 | *.RTF diff=astextplain
18 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | # User-specific files
5 | *.suo
6 | *.user
7 | *.userosscache
8 | *.sln.docstates
9 |
10 | # Build results
11 | [Dd]ebug/
12 | [Dd]ebugPublic/
13 | [Rr]elease/
14 | [Rr]eleases/
15 | x64/
16 | x86/
17 | build/
18 | bld/
19 | [Bb]in/
20 | [Oo]bj/
21 |
22 | # Roslyn cache directories
23 | *.ide/
24 |
25 | # MSTest test Results
26 | [Tt]est[Rr]esult*/
27 | [Bb]uild[Ll]og.*
28 |
29 | #NUNIT
30 | *.VisualState.xml
31 | TestResult.xml
32 |
33 | # Build Results of an ATL Project
34 | [Dd]ebugPS/
35 | [Rr]eleasePS/
36 | dlldata.c
37 |
38 | *_i.c
39 | *_p.c
40 | *_i.h
41 | *.ilk
42 | *.meta
43 | *.obj
44 | *.pch
45 | *.pdb
46 | *.pgc
47 | *.pgd
48 | *.rsp
49 | *.sbr
50 | *.tlb
51 | *.tli
52 | *.tlh
53 | *.tmp
54 | *.tmp_proj
55 | *.log
56 | *.vspscc
57 | *.vssscc
58 | .builds
59 | *.pidb
60 | *.svclog
61 | *.scc
62 |
63 | # Chutzpah Test files
64 | _Chutzpah*
65 |
66 | # Visual C++ cache files
67 | ipch/
68 | *.aps
69 | *.ncb
70 | *.opensdf
71 | *.sdf
72 | *.cachefile
73 |
74 | # Visual Studio profiler
75 | *.psess
76 | *.vsp
77 | *.vspx
78 |
79 | # TFS 2012 Local Workspace
80 | $tf/
81 |
82 | # Guidance Automation Toolkit
83 | *.gpState
84 |
85 | # ReSharper is a .NET coding add-in
86 | _ReSharper*/
87 | *.[Rr]e[Ss]harper
88 | *.DotSettings.user
89 |
90 | # JustCode is a .NET coding addin-in
91 | .JustCode
92 |
93 | # TeamCity is a build add-in
94 | _TeamCity*
95 |
96 | # DotCover is a Code Coverage Tool
97 | *.dotCover
98 |
99 | # NCrunch
100 | _NCrunch_*
101 | .*crunch*.local.xml
102 |
103 | # MightyMoose
104 | *.mm.*
105 | AutoTest.Net/
106 |
107 | # Web workbench (sass)
108 | .sass-cache/
109 |
110 | # Installshield output folder
111 | [Ee]xpress/
112 |
113 | # DocProject is a documentation generator add-in
114 | DocProject/buildhelp/
115 | DocProject/Help/*.HxT
116 | DocProject/Help/*.HxC
117 | DocProject/Help/*.hhc
118 | DocProject/Help/*.hhk
119 | DocProject/Help/*.hhp
120 | DocProject/Help/Html2
121 | DocProject/Help/html
122 |
123 | # Click-Once directory
124 | publish/
125 |
126 | # Publish Web Output
127 | *.[Pp]ublish.xml
128 | *.azurePubxml
129 | # TODO: Comment the next line if you want to checkin your web deploy settings
130 | # but database connection strings (with potential passwords) will be unencrypted
131 | *.pubxml
132 | *.publishproj
133 |
134 | # NuGet Packages
135 | *.nupkg
136 | # The packages folder can be ignored because of Package Restore
137 | **/packages/*
138 | # except build/, which is used as an MSBuild target.
139 | !**/packages/build/
140 | # If using the old MSBuild-Integrated Package Restore, uncomment this:
141 | #!**/packages/repositories.config
142 |
143 | # Windows Azure Build Output
144 | csx/
145 | *.build.csdef
146 |
147 | # Windows Store app package directory
148 | AppPackages/
149 |
150 | # Others
151 | sql/
152 | *.Cache
153 | ClientBin/
154 | [Ss]tyle[Cc]op.*
155 | ~$*
156 | *~
157 | *.dbmdl
158 | *.dbproj.schemaview
159 | *.pfx
160 | *.publishsettings
161 | node_modules/
162 |
163 | # RIA/Silverlight projects
164 | Generated_Code/
165 |
166 | # Backup & report files from converting an old project file
167 | # to a newer Visual Studio version. Backup files are not needed,
168 | # because we have git ;-)
169 | _UpgradeReport_Files/
170 | Backup*/
171 | UpgradeLog*.XML
172 | UpgradeLog*.htm
173 |
174 | # SQL Server files
175 | *.mdf
176 | *.ldf
177 |
178 | # Business Intelligence projects
179 | *.rdl.data
180 | *.bim.layout
181 | *.bim_*.settings
182 |
183 | # Microsoft Fakes
184 | FakesAssemblies/
185 |
186 | # =========================
187 | # Operating System Files
188 | # =========================
189 |
190 | # OSX
191 | # =========================
192 |
193 | .DS_Store
194 | .AppleDouble
195 | .LSOverride
196 |
197 | # Thumbnails
198 | ._*
199 |
200 | # Files that might appear on external disk
201 | .Spotlight-V100
202 | .Trashes
203 |
204 | # Directories potentially created on remote AFP share
205 | .AppleDB
206 | .AppleDesktop
207 | Network Trash Folder
208 | Temporary Items
209 | .apdisk
210 |
211 | # Windows
212 | # =========================
213 |
214 | # Windows image file caches
215 | Thumbs.db
216 | ehthumbs.db
217 |
218 | # Folder config file
219 | Desktop.ini
220 |
221 | # Recycle Bin used on file shares
222 | $RECYCLE.BIN/
223 |
224 | # Windows Installer files
225 | *.cab
226 | *.msi
227 | *.msm
228 | *.msp
229 |
230 | # Windows shortcuts
231 | *.lnk
232 |
--------------------------------------------------------------------------------
/AppVeyor.Api.Tests/AppVeyor.Api.Tests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | AnyCPU
6 | {4F809422-2D0C-4751-A91E-64B68AB9039D}
7 | Library
8 | Properties
9 | AppVeyor.Api.Tests
10 | AppVeyor.Api.Tests
11 | v4.5
12 | 512
13 | {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
14 | 10.0
15 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)
16 | $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages
17 | False
18 | UnitTest
19 | SAK
20 | SAK
21 | SAK
22 | SAK
23 | ..\
24 |
25 |
26 | true
27 | full
28 | false
29 | bin\Debug\
30 | DEBUG;TRACE
31 | prompt
32 | 4
33 |
34 |
35 | pdbonly
36 | true
37 | bin\Release\
38 | TRACE
39 | prompt
40 | 4
41 |
42 |
43 |
44 | ..\packages\FakeItEasy.2.0.0-beta009\lib\net40\FakeItEasy.dll
45 | True
46 |
47 |
48 | ..\packages\NBuilder.3.0.1.1\lib\FizzWare.NBuilder.dll
49 | True
50 |
51 |
52 | ..\packages\Moq.4.2.1507.0118\lib\net40\Moq.dll
53 | True
54 |
55 |
56 | ..\packages\RestSharp.105.2.3\lib\net45\RestSharp.dll
57 | True
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 | {1e4ac15d-7590-4a7d-9c1b-8b0cce9582fd}
80 | AppVeyor.Api
81 |
82 |
83 | {262035FB-98EC-4E05-ADEF-3A4104962E36}
84 | AppVeyor.Common
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 | False
95 |
96 |
97 | False
98 |
99 |
100 | False
101 |
102 |
103 | False
104 |
105 |
106 |
107 |
108 |
109 |
110 |
117 |
--------------------------------------------------------------------------------
/AppVeyor.Api.Tests/ProjectApiTest.cs:
--------------------------------------------------------------------------------
1 | using System.Threading.Tasks;
2 | using Microsoft.VisualStudio.TestTools.UnitTesting;
3 |
4 | namespace AppVeyor.Api.Tests
5 | {
6 | [TestClass]
7 | public class ProjectApiTest
8 | {
9 | private AppVeyorService _appVeyorService;
10 |
11 | [TestInitialize]
12 | public void Init()
13 | {
14 | _appVeyorService = new AppVeyorService("YOUR_ACCOUNT_API_KEY_HERE");
15 | }
16 |
17 | [TestMethod]
18 | [Ignore]
19 | public void GetProjects_Test()
20 | {
21 | var projects = _appVeyorService.ProjectApi.GetProjects();
22 |
23 |
24 | }
25 |
26 | [TestMethod]
27 | public async Task GetProjectsAsync_Test()
28 | {
29 | var projects = await _appVeyorService.ProjectApi.GetProjectsAsync();
30 | Assert.IsTrue(!projects.HasError && projects.Result != null && projects.Result.Count > 0);
31 | }
32 |
33 | [TestMethod]
34 | public async Task Get_Project_Last_Build_Test()
35 | {
36 | var projectSlug = "vsostatusinspector";
37 | var accountName = "onlyutkarsh";
38 | var buildInfo = await _appVeyorService.ProjectApi.GetLastBuild(accountName, projectSlug);
39 | Assert.IsTrue(buildInfo.Build != null && buildInfo.Project.Slug == projectSlug);
40 | }
41 |
42 | [TestMethod]
43 | public async Task Get_Project_By_Build_Version_Test()
44 | {
45 | var projectSlug = "vsostatusinspector";
46 | var accountName = "onlyutkarsh";
47 | var version = "1.0.1";
48 | var buildInfo = await _appVeyorService.ProjectApi.GetBuildByVersion(accountName, projectSlug, version);
49 | Assert.IsTrue(buildInfo.Build != null && buildInfo.Project.Slug == projectSlug);
50 | }
51 |
52 | [TestMethod]
53 | public async Task Get_Project_History()
54 | {
55 | var projectSlug = "vsostatusinspector";
56 | var accountName = "onlyutkarsh";
57 | var buildInfo = await _appVeyorService.ProjectApi.GetProjectHistory(accountName, projectSlug);
58 | Assert.IsTrue(buildInfo.Builds.Count == 10 && buildInfo.Project.Slug == projectSlug);
59 | }
60 |
61 | [TestMethod]
62 | public async Task Get_Project_History_With_BranchName()
63 | {
64 | var projectSlug = "vsostatusinspector";
65 | var accountName = "onlyutkarsh";
66 | var branchName = "master";
67 | var buildInfo = await _appVeyorService.ProjectApi.GetProjectHistory(accountName, projectSlug, branchName: branchName);
68 | Assert.IsTrue(buildInfo.Builds.Count == 10 && buildInfo.Project.Slug == projectSlug);
69 | }
70 |
71 |
72 | [TestMethod]
73 | public async Task Cancel_Build()
74 | {
75 | var projectSlug = "dropdownlinkbutton";
76 | var accountName = "onlyutkarsh";
77 | var branchName = "master";
78 | var build = await _appVeyorService.ProjectApi.CancelBuild(accountName, projectSlug, branchName);
79 | //Assert.IsTrue(build.BuildId != 0 && build.Status.First() == "queued");
80 | }
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/AppVeyor.Api.Tests/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.InteropServices;
3 |
4 | // General Information about an assembly is controlled through the following
5 | // set of attributes. Change these attribute values to modify the information
6 | // associated with an assembly.
7 | [assembly: AssemblyTitle("AppVeyor.Api.Tests")]
8 | [assembly: AssemblyDescription("")]
9 | [assembly: AssemblyConfiguration("")]
10 | [assembly: AssemblyCompany("")]
11 | [assembly: AssemblyProduct("AppVeyor.Api.Tests")]
12 | [assembly: AssemblyCopyright("Copyright © 2015")]
13 | [assembly: AssemblyTrademark("")]
14 | [assembly: AssemblyCulture("")]
15 |
16 | // Setting ComVisible to false makes the types in this assembly not visible
17 | // to COM components. If you need to access a type in this assembly from
18 | // COM, set the ComVisible attribute to true on that type.
19 | [assembly: ComVisible(false)]
20 |
21 | // The following GUID is for the ID of the typelib if this project is exposed to COM
22 | [assembly: Guid("d6aaca98-61bb-43dc-96b4-ed21a4646050")]
23 |
24 | // Version information for an assembly consists of the following four values:
25 | //
26 | // Major Version
27 | // Minor Version
28 | // Build Number
29 | // Revision
30 | //
31 | // You can specify all the values or you can default the Build and Revision Numbers
32 | // by using the '*' as shown below:
33 | // [assembly: AssemblyVersion("1.0.*")]
34 | [assembly: AssemblyVersion("1.0.0.0")]
35 | [assembly: AssemblyFileVersion("1.0.0.0")]
36 |
--------------------------------------------------------------------------------
/AppVeyor.Api.Tests/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/AppVeyor.Api/AppVeyor.Api.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {1E4AC15D-7590-4A7D-9C1B-8B0CCE9582FD}
8 | Library
9 | Properties
10 | AppVeyor.Api
11 | AppVeyor.Api
12 | v4.5
13 | 512
14 | SAK
15 | SAK
16 | SAK
17 | SAK
18 | ..\
19 |
20 |
21 | true
22 | full
23 | false
24 | bin\Debug\
25 | DEBUG;TRACE
26 | prompt
27 | 4
28 |
29 |
30 | pdbonly
31 | true
32 | bin\Release\
33 | TRACE
34 | prompt
35 | 4
36 |
37 |
38 | false
39 |
40 |
41 |
42 |
43 |
44 |
45 | false
46 |
47 |
48 |
49 | ..\packages\CuttingEdge.Conditions.1.2.0.0\lib\NET35\CuttingEdge.Conditions.dll
50 | True
51 |
52 |
53 | ..\packages\Microsoft.ApplicationInsights.1.2.0\lib\net45\Microsoft.ApplicationInsights.dll
54 | True
55 |
56 |
57 | ..\packages\RestSharp.105.2.3\lib\net45\RestSharp.dll
58 | True
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 | {262035fb-98ec-4e05-adef-3a4104962e36}
82 | AppVeyor.Common
83 |
84 |
85 |
86 |
93 |
--------------------------------------------------------------------------------
/AppVeyor.Api/AppVeyorService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using RestSharp;
3 |
4 | namespace AppVeyor.Api
5 | {
6 | public class AppVeyorService : IAppVeyorService
7 | {
8 | private readonly Uri _baseUrl = new Uri("https://ci.appveyor.com/api");
9 | private readonly ProjectApi _projectApi;
10 |
11 | public ProjectApi ProjectApi
12 | {
13 | get
14 | {
15 | return _projectApi;
16 | }
17 | }
18 |
19 | public AppVeyorService(string apiToken, Uri baseUrl = null)
20 | {
21 | if (baseUrl != null)
22 | _baseUrl = baseUrl;
23 |
24 | RestClient client = new RestClient(_baseUrl);
25 | _projectApi = new ProjectApi(client, apiToken);
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/AppVeyor.Api/AppVeyorServiceResponse.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace AppVeyor.Api
4 | {
5 | public class AppVeyorServiceResponse
6 | {
7 | public T Result { get; set; }
8 |
9 | public bool HasError { get; set; }
10 |
11 | public Exception Exception { get; set; }
12 | }
13 | }
--------------------------------------------------------------------------------
/AppVeyor.Api/IAppVeyorService.cs:
--------------------------------------------------------------------------------
1 | namespace AppVeyor.Api
2 | {
3 | public interface IAppVeyorService
4 | {
5 | }
6 | }
--------------------------------------------------------------------------------
/AppVeyor.Api/ProjectApi.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Net;
4 | using System.Threading.Tasks;
5 | using AppVeyor.Common.Entities;
6 | using CuttingEdge.Conditions;
7 | using RestSharp;
8 |
9 | namespace AppVeyor.Api
10 | {
11 | public class ProjectApi : Resource
12 | {
13 | public ProjectApi(IRestClient client, string apiToken)
14 | : base(client, apiToken)
15 | {
16 |
17 | }
18 |
19 | public List GetProjects()
20 | {
21 | var request = new RestRequest("projects", Method.GET);
22 |
23 | var projects = Execute>(request);
24 | return projects;
25 | }
26 |
27 | public async Task>> GetProjectsAsync()
28 | {
29 | var request = new RestRequest("projects", Method.GET);
30 | var response = new AppVeyorServiceResponse>();
31 | try
32 | {
33 | var projects = await ExecuteAsync>(request);
34 | response.Result = projects;
35 | }
36 | catch (Exception exception)
37 | {
38 | response.Exception = exception;
39 | response.HasError = true;
40 | }
41 |
42 | return response;
43 | }
44 |
45 | public Task GetLastBuild(string accountName, string projectSlug)
46 | {
47 | var request = new RestRequest("projects/{accountName}/{projectSlug}", Method.GET);
48 | request.AddUrlSegment("accountName", accountName);
49 | request.AddUrlSegment("projectSlug", projectSlug);
50 |
51 | return ExecuteAsync(request);
52 | }
53 |
54 | public Task GetBuildByVersion(string accountName, string projectSlug, string buildVersion)
55 | {
56 | var request = new RestRequest("projects/{accountName}/{projectSlug}/build/{buildVersion}", Method.GET);
57 | request.AddUrlSegment("accountName", accountName);
58 | request.AddUrlSegment("projectSlug", projectSlug);
59 | request.AddUrlSegment("buildVersion", buildVersion);
60 |
61 | return ExecuteAsync(request);
62 | }
63 |
64 | public Task GetProjectHistory(string accountName, string projectSlug, int noOfrecordsPerPage = 10, Guid buildId = default(Guid), string branchName = null)
65 | {
66 | var request = new RestRequest("projects/{accountName}/{projectSlug}/history", Method.GET);
67 | request.AddUrlSegment("accountName", accountName);
68 | request.AddUrlSegment("projectSlug", projectSlug);
69 | request.AddParameter("recordsNumber", noOfrecordsPerPage);
70 | if (buildId != Guid.Empty)
71 | {
72 | request.AddParameter("startBuildId", buildId);
73 | }
74 | if (!string.IsNullOrEmpty(branchName))
75 | {
76 | request.AddParameter("branch", branchName);
77 | }
78 | return ExecuteAsync(request);
79 | }
80 |
81 | public virtual async Task> StartBuild(string accountName, string projectSlug, string branchName)
82 | {
83 | var response = new AppVeyorServiceResponse();
84 | try
85 | {
86 | Condition.Requires(accountName, "accountName").IsNotNullOrEmpty();
87 | Condition.Requires(projectSlug, "projectSlug").IsNotNullOrEmpty();
88 | Condition.Requires(branchName, "branchName").IsNotNullOrEmpty();
89 | var request = new RestRequest("builds", Method.POST);
90 | request.AddJsonBody(new
91 | {
92 | accountName,
93 | projectSlug,
94 | branch = branchName
95 | });
96 | var build = await ExecuteAsync(request);
97 | response.Result = build;
98 | }
99 | catch (Exception exception)
100 | {
101 | response.Exception = exception;
102 | response.HasError = true;
103 | }
104 | return response;
105 | }
106 |
107 | public async Task> CancelBuild(string accountName, string projectSlug, string buildVersion)
108 | {
109 | var response = new AppVeyorServiceResponse();
110 | try
111 | {
112 | Condition.Requires(accountName, "accountName").IsNotNullOrEmpty();
113 | Condition.Requires(projectSlug, "projectSlug").IsNotNullOrEmpty();
114 | Condition.Requires(buildVersion, "buildVersion").IsNotNullOrEmpty();
115 | var request = new RestRequest("builds/{accountName}/{projectSlug}/{buildVersion}", Method.DELETE);
116 | request.AddUrlSegment("accountName", accountName);
117 | request.AddUrlSegment("projectSlug", projectSlug);
118 | request.AddUrlSegment("buildVersion", buildVersion);
119 | var stopResult = await ExecuteAsync(request);
120 | response.Result = stopResult;
121 |
122 | }
123 | catch (Exception exception)
124 | {
125 | response.Exception = exception;
126 | response.HasError = true;
127 | }
128 | return response;
129 |
130 | }
131 | }
132 |
133 | }
134 |
--------------------------------------------------------------------------------
/AppVeyor.Api/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.InteropServices;
3 |
4 | // General Information about an assembly is controlled through the following
5 | // set of attributes. Change these attribute values to modify the information
6 | // associated with an assembly.
7 | [assembly: AssemblyTitle("AppVeyor.Api")]
8 | [assembly: AssemblyDescription("")]
9 | [assembly: AssemblyConfiguration("")]
10 | [assembly: AssemblyCompany("")]
11 | [assembly: AssemblyProduct("AppVeyor.Api")]
12 | [assembly: AssemblyCopyright("Copyright © 2015")]
13 | [assembly: AssemblyTrademark("")]
14 | [assembly: AssemblyCulture("")]
15 |
16 | // Setting ComVisible to false makes the types in this assembly not visible
17 | // to COM components. If you need to access a type in this assembly from
18 | // COM, set the ComVisible attribute to true on that type.
19 | [assembly: ComVisible(false)]
20 |
21 | // The following GUID is for the ID of the typelib if this project is exposed to COM
22 | [assembly: Guid("4b9757a8-6b7e-4f67-8d4b-ed14a9759796")]
23 |
24 | // Version information for an assembly consists of the following four values:
25 | //
26 | // Major Version
27 | // Minor Version
28 | // Build Number
29 | // Revision
30 | //
31 | // You can specify all the values or you can default the Build and Revision Numbers
32 | // by using the '*' as shown below:
33 | // [assembly: AssemblyVersion("1.0.*")]
34 | [assembly: AssemblyVersion("1.0.0.0")]
35 | [assembly: AssemblyFileVersion("1.0.0.0")]
36 |
--------------------------------------------------------------------------------
/AppVeyor.Api/Resource.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Diagnostics;
3 | using System.Net;
4 | using System.Threading.Tasks;
5 | using AppVeyor.Common;
6 | using AppVeyor.Common.Exceptions;
7 | using RestSharp;
8 |
9 | namespace AppVeyor.Api
10 | {
11 | public class Resource
12 | {
13 | private readonly IRestClient _client;
14 | private readonly string _apiToken;
15 |
16 | protected Resource(IRestClient client, string apiToken)
17 | {
18 | _client = client;
19 | _apiToken = apiToken;
20 | }
21 |
22 | internal IRestResponse Execute(IRestRequest request)
23 | {
24 | AddHeaderInfo(request);
25 | IRestResponse response = _client.Execute(request);
26 |
27 | return response;
28 | }
29 |
30 | internal T Execute(IRestRequest request) where T : new()
31 | {
32 | AddHeaderInfo(request);
33 | IRestResponse response = _client.Execute(request);
34 | if (response.ErrorException != null)
35 | {
36 | const string message = "Error retrieving response. Check inner details for more info.";
37 | var applicationException = new ApplicationException(message, response.ErrorException);
38 | throw applicationException;
39 | }
40 | return response.Data;
41 | }
42 |
43 | internal void ExecuteAsync(IRestRequest request, Action callback) where T : new()
44 | {
45 | AddHeaderInfo(request);
46 | var tcs = new TaskCompletionSource();
47 | _client.ExecuteAsync(request, response =>
48 | {
49 | if (response.ErrorException != null)
50 | tcs.TrySetException(response.ErrorException);
51 | else
52 | tcs.TrySetResult(response.Data);
53 | callback(response.Data);
54 | });
55 | }
56 |
57 | public Task ExecuteAsync(IRestRequest request) where T : new()
58 | {
59 | AddHeaderInfo(request);
60 | _client.UserAgent = "AppVeyor/1.0";
61 | var tcs = new TaskCompletionSource();
62 |
63 | _client.ExecuteAsync(request, response =>
64 | {
65 | var stopWatch = new Stopwatch();
66 | stopWatch.Start();
67 | if (response.ErrorException != null)
68 | {
69 | stopWatch.Stop();
70 | Telemetry.Instance.TrackRequest(request.Resource.ToString(), DateTimeOffset.UtcNow, stopWatch.Elapsed, response.StatusCode.ToString(), false);
71 |
72 | tcs.TrySetException(response.ErrorException);
73 | }
74 | else if (response.StatusCode == HttpStatusCode.OK || response.StatusCode == HttpStatusCode.NoContent)
75 | {
76 | stopWatch.Stop();
77 | Telemetry.Instance.TrackRequest(request.Resource.ToString(), DateTimeOffset.UtcNow, stopWatch.Elapsed, response.StatusCode.ToString(), true);
78 |
79 | tcs.TrySetResult(response.Data);
80 | }
81 | else if (response.StatusCode == HttpStatusCode.Unauthorized)
82 | {
83 | stopWatch.Stop();
84 | Telemetry.Instance.TrackRequest(request.Resource.ToString(), DateTimeOffset.UtcNow, stopWatch.Elapsed, response.StatusCode.ToString(), false);
85 |
86 | tcs.TrySetException(
87 | new AppVeyorUnauthorizedException("Unable to authorize with AppVeyor. Please check if your API token is correct."));
88 | }
89 | else
90 | {
91 | stopWatch.Stop();
92 | Telemetry.Instance.TrackRequest(request.Resource.ToString(), DateTimeOffset.UtcNow, stopWatch.Elapsed, response.StatusCode.ToString(), false);
93 |
94 | var errorMessage = !string.IsNullOrEmpty(response.ErrorMessage)
95 | ? response.ErrorMessage
96 | : string.Format("Error: {0}, Status Code: {1}", response.StatusDescription, (int)response.StatusCode);
97 | tcs.TrySetException(new ApplicationException(errorMessage));
98 | }
99 |
100 | });
101 |
102 | return tcs.Task;
103 | }
104 | private void AddHeaderInfo(IRestRequest request)
105 | {
106 | request.AddHeader("Accept", "application/json");
107 | request.AddHeader("Authorization", string.Format("Bearer {0}", _apiToken));
108 | }
109 |
110 | }
111 | }
--------------------------------------------------------------------------------
/AppVeyor.Api/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/AppVeyor.Common/AppVeyor.Common.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {262035FB-98EC-4E05-ADEF-3A4104962E36}
8 | Library
9 | Properties
10 | AppVeyor.Common
11 | AppVeyor.Common
12 | v4.5
13 | 512
14 | SAK
15 | SAK
16 | SAK
17 | SAK
18 | ..\
19 |
20 |
21 | true
22 | full
23 | false
24 | bin\Debug\
25 | DEBUG;TRACE
26 | prompt
27 | 4
28 |
29 |
30 | pdbonly
31 | true
32 | bin\Release\
33 | TRACE
34 | prompt
35 | 4
36 |
37 |
38 |
39 | ..\packages\CuttingEdge.Conditions.1.2.0.0\lib\NET35\CuttingEdge.Conditions.dll
40 | True
41 |
42 |
43 | ..\packages\Microsoft.ApplicationInsights.1.2.0\lib\net45\Microsoft.ApplicationInsights.dll
44 | True
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 | Designer
82 |
83 |
84 |
85 |
86 |
93 |
--------------------------------------------------------------------------------
/AppVeyor.Common/Aspects/TrackUsage.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Diagnostics;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using PostSharp.Aspects;
8 |
9 | namespace AppVeyor.Common.Aspects
10 | {
11 | [Serializable]
12 | public class TrackUsage : OnMethodBoundaryAspect
13 | {
14 | public override void OnEntry(MethodExecutionArgs args)
15 | {
16 |
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/AppVeyor.Common/AsyncManualResetEvent.cs:
--------------------------------------------------------------------------------
1 | using System.Threading;
2 | using System.Threading.Tasks;
3 |
4 | namespace AppVeyor.Common
5 | {
6 | public class AsyncManualResetEvent
7 | {
8 | private volatile TaskCompletionSource m_tcs = new TaskCompletionSource();
9 |
10 | public Task WaitAsync() { return m_tcs.Task; }
11 |
12 | public void Set()
13 | {
14 | var tcs = m_tcs;
15 | Task.Factory.StartNew(s => ((TaskCompletionSource)s).TrySetResult(true),
16 | tcs, CancellationToken.None, TaskCreationOptions.PreferFairness, TaskScheduler.Default);
17 | tcs.Task.Wait();
18 | }
19 |
20 | public void Reset()
21 | {
22 | while (true)
23 | {
24 | var tcs = m_tcs;
25 | if (!tcs.Task.IsCompleted ||
26 | Interlocked.CompareExchange(ref m_tcs, new TaskCompletionSource(), tcs) == tcs)
27 | return;
28 | }
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/AppVeyor.Common/BuildStatus.cs:
--------------------------------------------------------------------------------
1 | namespace AppVeyor.Common
2 | {
3 | public enum BuildStatus
4 | {
5 | Running,
6 | Success,
7 | Queued,
8 | Failed,
9 | Cancelled,
10 | Unknown,
11 | }
12 | }
--------------------------------------------------------------------------------
/AppVeyor.Common/Entities/AccessRight.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 |
3 | namespace AppVeyor.Common.Entities
4 | {
5 | [Obfuscation(Feature = "trigger", Exclude = false)]
6 | public class AccessRight
7 | {
8 |
9 | public string Name { get; set; }
10 |
11 | public bool Allowed { get; set; }
12 | }
13 | }
--------------------------------------------------------------------------------
/AppVeyor.Common/Entities/AccessRightDefinition.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 |
3 | namespace AppVeyor.Common.Entities
4 | {
5 | [Obfuscation(Feature = "trigger", Exclude = false)]
6 | public class AccessRightDefinition
7 | {
8 |
9 | public string Name { get; set; }
10 |
11 | public string Description { get; set; }
12 | }
13 | }
--------------------------------------------------------------------------------
/AppVeyor.Common/Entities/Build.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Reflection;
3 |
4 | namespace AppVeyor.Common.Entities
5 | {
6 | [Obfuscation(Feature = "trigger", Exclude = false)]
7 | public class Build
8 | {
9 | public int BuildId { get; set; }
10 |
11 | public List Jobs { get; set; }
12 |
13 | public int BuildNumber { get; set; }
14 |
15 | public string Version { get; set; }
16 |
17 | public string Message { get; set; }
18 |
19 | public string Branch { get; set; }
20 |
21 | public string CommitId { get; set; }
22 |
23 | public string AuthorName { get; set; }
24 |
25 | public string AuthorUsername { get; set; }
26 |
27 | public string CommitterName { get; set; }
28 |
29 | public string CommitterUsername { get; set; }
30 |
31 | public string Committed { get; set; }
32 |
33 | public List Messages { get; set; }
34 |
35 | public List Status { get; set; }
36 |
37 | public string Started { get; set; }
38 |
39 | public string Finished { get; set; }
40 |
41 | public string Created { get; set; }
42 |
43 | public string Updated { get; set; }
44 | }
45 | }
--------------------------------------------------------------------------------
/AppVeyor.Common/Entities/BuildInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 |
3 | namespace AppVeyor.Common.Entities
4 | {
5 | [Obfuscation(Feature = "trigger", Exclude = false)]
6 | public class BuildInfo
7 | {
8 | public Project Project { get; set; }
9 |
10 | public Build Build { get; set; }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/AppVeyor.Common/Entities/Job.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 |
3 | namespace AppVeyor.Common.Entities
4 | {
5 | [Obfuscation(Feature = "trigger", Exclude = false)]
6 | public class Job
7 | {
8 |
9 | public string JobId { get; set; }
10 |
11 | public string Name { get; set; }
12 |
13 | public bool AllowFailure { get; set; }
14 |
15 | public int MessagesCount { get; set; }
16 |
17 | public int CompilationMessagesCount { get; set; }
18 |
19 | public int CompilationErrorsCount { get; set; }
20 |
21 | public int CompilationWarningsCount { get; set; }
22 |
23 | public int TestsCount { get; set; }
24 |
25 | public int PassedTestsCount { get; set; }
26 |
27 | public int FailedTestsCount { get; set; }
28 |
29 | public int ArtifactsCount { get; set; }
30 |
31 | public string Status { get; set; }
32 |
33 | public string Started { get; set; }
34 |
35 | public string Finished { get; set; }
36 |
37 | public string Created { get; set; }
38 |
39 | public string Updated { get; set; }
40 | }
41 |
42 | }
--------------------------------------------------------------------------------
/AppVeyor.Common/Entities/NuGetFeed.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 |
3 | namespace AppVeyor.Common.Entities
4 | {
5 | [Obfuscation(Feature = "trigger", Exclude = false)]
6 | public class NuGetFeed
7 | {
8 | public string Id { get; set; }
9 | public string Name { get; set; }
10 | public bool PublishingEnabled { get; set; }
11 | public string Created { get; set; }
12 | }
13 | }
--------------------------------------------------------------------------------
/AppVeyor.Common/Entities/Project.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Reflection;
3 |
4 | namespace AppVeyor.Common.Entities
5 | {
6 |
7 | [Obfuscation(Feature = "trigger", Exclude = false)]
8 | public class Project
9 | {
10 | public int ProjectId { get; set; }
11 |
12 | public int AccountId { get; set; }
13 |
14 | public string AccountName { get; set; }
15 |
16 | public List Builds { get; set; }
17 |
18 | public string Name { get; set; }
19 |
20 | public string Slug { get; set; }
21 |
22 | public string RepositoryType { get; set; }
23 |
24 | public string RepositoryScm { get; set; }
25 |
26 | public string RepositoryName { get; set; }
27 |
28 | public string RepositoryBranch { get; set; }
29 |
30 | public bool IsPrivate { get; set; }
31 |
32 | public bool SkipBranchesWithoutAppveyorYml { get; set; }
33 |
34 | public NuGetFeed NuGetFeed { get; set; }
35 |
36 | public string Created { get; set; }
37 |
38 | public SecurityDescriptor SecurityDescriptor { get; set; }
39 |
40 |
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/AppVeyor.Common/Entities/ProjectHistory.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Reflection;
3 |
4 | namespace AppVeyor.Common.Entities
5 | {
6 | [Obfuscation(Feature = "trigger", Exclude = false)]
7 | public class ProjectHistory
8 | {
9 | public Project Project { get; set; }
10 |
11 | public List Builds { get; set; }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/AppVeyor.Common/Entities/RoleAce.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Reflection;
3 |
4 | namespace AppVeyor.Common.Entities
5 | {
6 | [Obfuscation(Feature = "trigger", Exclude = false)]
7 | public class RoleAce
8 | {
9 |
10 | public int RoleId { get; set; }
11 |
12 | public string Name { get; set; }
13 |
14 | public bool IsAdmin { get; set; }
15 |
16 | public List AccessRights { get; set; }
17 | }
18 | }
--------------------------------------------------------------------------------
/AppVeyor.Common/Entities/SecurityDescriptor.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Reflection;
3 |
4 | namespace AppVeyor.Common.Entities
5 | {
6 | [Obfuscation(Feature = "trigger", Exclude = false)]
7 | public class SecurityDescriptor
8 | {
9 | public List AccessRightDefinitions { get; set; }
10 |
11 | public List RoleAces { get; set; }
12 | }
13 | }
--------------------------------------------------------------------------------
/AppVeyor.Common/Exceptions/AppVeyorException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Runtime.Serialization;
3 |
4 | namespace AppVeyor.Common.Exceptions
5 | {
6 | public class AppVeyorException: Exception
7 | {
8 | public AppVeyorException()
9 | { }
10 |
11 | public AppVeyorException(string message)
12 | : base(message) { }
13 |
14 | public AppVeyorException(string format, params object[] args)
15 | : base(string.Format(format, args)) { }
16 |
17 | public AppVeyorException(string message, Exception innerException)
18 | : base(message, innerException) { }
19 |
20 | public AppVeyorException(string format, Exception innerException, params object[] args)
21 | : base(string.Format(format, args), innerException) { }
22 |
23 | protected AppVeyorException(SerializationInfo info, StreamingContext context)
24 | : base(info, context) { }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/AppVeyor.Common/Exceptions/AppVeyorUnauthorizedException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Runtime.Serialization;
3 |
4 | namespace AppVeyor.Common.Exceptions
5 | {
6 | [Serializable]
7 | public class AppVeyorUnauthorizedException : Exception
8 | {
9 | public AppVeyorUnauthorizedException()
10 | { }
11 |
12 | public AppVeyorUnauthorizedException(string message)
13 | : base(message) { }
14 |
15 | public AppVeyorUnauthorizedException(string format, params object[] args)
16 | : base(string.Format(format, args)) { }
17 |
18 | public AppVeyorUnauthorizedException(string message, Exception innerException)
19 | : base(message, innerException) { }
20 |
21 | public AppVeyorUnauthorizedException(string format, Exception innerException, params object[] args)
22 | : base(string.Format(format, args), innerException) { }
23 |
24 | protected AppVeyorUnauthorizedException(SerializationInfo info, StreamingContext context)
25 | : base(info, context) { }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/AppVeyor.Common/Extensions/DateTimeExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace AppVeyor.Common.Extensions
4 | {
5 | public static class DateTimeExtensions
6 | {
7 | public enum Precision
8 | {
9 | Second,
10 | Minute,
11 | Hour,
12 | Day,
13 | Week,
14 | Month,
15 | Year,
16 | None
17 | }
18 | public static DateTime Round(this DateTime date, TimeSpan span)
19 | {
20 | long ticks = (date.Ticks + (span.Ticks / 2) + 1) / span.Ticks;
21 | return new DateTime(ticks * span.Ticks);
22 | }
23 |
24 | public static DateTime Floor(this DateTime date, TimeSpan span)
25 | {
26 | long ticks = (date.Ticks / span.Ticks);
27 | return new DateTime(ticks * span.Ticks);
28 | }
29 |
30 | public static DateTime Ceil(this DateTime date, TimeSpan span)
31 | {
32 | long ticks = (date.Ticks + span.Ticks - 1) / span.Ticks;
33 | return new DateTime(ticks * span.Ticks);
34 | }
35 |
36 | public static string PrettyDate(this DateTime timeSubmitted)
37 | {
38 | // accepts standard DateTime: 5/12/2011 2:36:00 PM
39 | // returns: "# month(s)/week(s)/day(s)/hour(s)/minute(s)/second(s)) ago"
40 | string prettyDate;
41 |
42 | TimeSpan diff = DateTime.Now - timeSubmitted;
43 |
44 | if (diff.Seconds <= 0)
45 | {
46 | prettyDate = timeSubmitted.ToString("dd, MMM, yyyy");
47 | }
48 | else if (diff.Days > 365 )
49 | {
50 | var year = Math.Round(diff.Days / 365.0);
51 | prettyDate = String.Format("{0} year{1}ago", year, (year >= 2 ? "s " : " "));
52 | }
53 | else if (diff.Days > 30)
54 | {
55 | var month = Math.Round(diff.Days / 30.0);
56 | prettyDate = String.Format("{0} month{1}ago", month, (month >= 2 ? "s " : " "));
57 | }
58 | else if (diff.Days > 7)
59 | {
60 | var week = Math.Round(diff.Days / 7.0);
61 | prettyDate = String.Format("{0} week{1}ago", week, (week >= 2 ? "s " : " "));
62 | }
63 | else if (diff.Days >= 1)
64 | {
65 | prettyDate = String.Format("{0} day{1}ago", diff.Days, (diff.Days >= 2 ? "s " : " "));
66 | }
67 | else if (diff.Hours >= 1)
68 | {
69 | prettyDate = String.Format("{0} hour{1}ago", diff.Hours, (diff.Hours >= 2 ? "s " : " "));
70 | }
71 | else if (diff.Minutes >= 1)
72 | {
73 | prettyDate = String.Format("{0} minute{1}ago", diff.Minutes, (diff.Minutes >= 2 ? "s " : " "));
74 | }
75 | else
76 | {
77 | prettyDate = String.Format("{0} second{1}ago", diff.Seconds, (diff.Seconds >= 2 ? "s " : " "));
78 | }
79 | return prettyDate;
80 | }
81 |
82 | public static string PrettyDate(this string timeSubmitted)
83 | {
84 | DateTime date;
85 | if (DateTime.TryParse(timeSubmitted, out date))
86 | {
87 | return date.PrettyDate();
88 | }
89 | return "Invalid Date";
90 | }
91 |
92 | public static string GetHumanizedRunningFromTime(this string startedTime)
93 | {
94 | DateTime startedAt;
95 | if (DateTime.TryParse(startedTime, out startedAt))
96 | {
97 | var timeSpan = DateTime.Now.Subtract(startedAt);
98 | return string.Format(" - {0} min {1} sec", timeSpan.Minutes, timeSpan.Seconds);
99 |
100 | };
101 | return string.Empty;
102 |
103 | }
104 | }
105 | }
106 |
--------------------------------------------------------------------------------
/AppVeyor.Common/Extensions/EnumerableExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Collections.ObjectModel;
4 | using System.Linq;
5 |
6 | namespace AppVeyor.Common.Extensions
7 | {
8 | public static class EnumerableExtensions
9 | {
10 | public static Boolean IsEmpty(this IEnumerable source)
11 | {
12 | if (source == null)
13 | return true; // or throw an exception
14 | return !source.Any();
15 | }
16 |
17 | public static bool DictionaryEqual(this IDictionary first, IDictionary second)
18 | {
19 | return first.DictionaryEqual(second, null);
20 | }
21 |
22 | public static bool DictionaryEqual(
23 | this IDictionary first, IDictionary second,
24 | IEqualityComparer valueComparer)
25 | {
26 | if (first == second) return true;
27 | if ((first == null) || (second == null)) return false;
28 | if (first.Count != second.Count) return false;
29 |
30 | valueComparer = valueComparer ?? EqualityComparer.Default;
31 |
32 | foreach (var kvp in first)
33 | {
34 | TValue secondValue;
35 | if (!second.TryGetValue(kvp.Key, out secondValue)) return false;
36 | if (!valueComparer.Equals(kvp.Value, secondValue)) return false;
37 | }
38 | return true;
39 | }
40 |
41 | public static bool ListEqual(this ObservableCollection first, ObservableCollection second, IEqualityComparer comparer)
42 | {
43 | if (first == second)
44 | return true;
45 |
46 | if (first == second) return true;
47 | if ((first == null) || (second == null)) return false;
48 | if (first.Count != second.Count) return false;
49 |
50 | comparer = comparer ?? EqualityComparer.Default;
51 |
52 | for (int index = 0; index < first.Count; index++)
53 | {
54 | var firstValue = first[index];
55 | var secondValue = second[index];
56 | if (!comparer.Equals(firstValue, secondValue))
57 | return false;
58 | }
59 | return true;
60 | }
61 |
62 | public static ObservableCollection ToObservableCollection(this IEnumerable coll)
63 | {
64 | var c = new ObservableCollection();
65 | foreach (var e in coll)
66 | {
67 | c.Add(e);
68 | }
69 |
70 | return c;
71 | }
72 | }
73 |
74 | }
75 |
--------------------------------------------------------------------------------
/AppVeyor.Common/Extensions/ProjectExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using AppVeyor.Common.Entities;
4 |
5 | namespace AppVeyor.Common.Extensions
6 | {
7 | public static class ProjectExtensions
8 | {
9 | public static bool IsInProgress(this Project project)
10 | {
11 | var builds = project.Builds.FirstOrDefault();
12 |
13 | if (builds != null && builds.Status.Any())
14 | {
15 | var status = builds.Status.First();
16 |
17 | return (status.EqualsToStatus(BuildStatus.Running)
18 | || status.EqualsToStatus(BuildStatus.Queued));
19 | }
20 | return false;
21 | }
22 | public static bool EqualsToStatus(this string statusString, BuildStatus buildStatus)
23 | {
24 | BuildStatus status;
25 | return Enum.TryParse(statusString, true, out status) && status == buildStatus;
26 | }
27 |
28 | public static string ToBuildStatusString(this string statusString)
29 | {
30 | BuildStatus status;
31 | return Enum.TryParse(statusString, true, out status) ? status.ToString() : BuildStatus.Unknown.ToString();
32 | }
33 |
34 | public static string ToBuildStatusString(this Project project)
35 | {
36 | var builds = project.Builds.FirstOrDefault();
37 |
38 | if (builds != null && builds.Status.Any())
39 | {
40 | var status = builds.Status.First();
41 | return status.ToBuildStatusString();
42 | }
43 | return "Unknown";
44 | }
45 |
46 | public static string ToLastRunString(this Project project, bool includeBuildDuration = false)
47 | {
48 | if (project != null && !project.Builds.IsEmpty())
49 | {
50 | var build = project.Builds.First();
51 | var status = build.Status.First();
52 | DateTime started;
53 | DateTime finished;
54 | DateTime.TryParse(build.Started, out started);
55 | DateTime.TryParse(build.Finished, out finished);
56 | BuildStatus buildStatus;
57 | Enum.TryParse(status, true, out buildStatus);
58 | switch (buildStatus)
59 | {
60 | case BuildStatus.Failed:
61 | case BuildStatus.Success:
62 | {
63 | if ((DateTime.TryParse(build.Started, out started) && started != DateTime.MinValue) &&
64 | (DateTime.TryParse(build.Finished, out finished) && finished != DateTime.MinValue) &&
65 | started < finished)
66 | {
67 | var runDuration = finished.Subtract(started);
68 | var lastRunStringWithBuildDuration = string.Format("{0} in {1} min {2} sec", started.PrettyDate(), runDuration.Minutes, runDuration.Seconds);
69 | var lastRunString = started.PrettyDate();
70 |
71 | return includeBuildDuration ? lastRunStringWithBuildDuration : lastRunString;
72 | }
73 | return started.PrettyDate();
74 | }
75 | case BuildStatus.Cancelled:
76 | {
77 | return string.Format("Cancelled {0}", finished.PrettyDate());
78 | }
79 | case BuildStatus.Queued:
80 | {
81 | return string.Format("Queued {0}", build.Created.GetHumanizedRunningFromTime());
82 | }
83 | case BuildStatus.Running:
84 | {
85 | return string.Format("Running {0}", build.Started.GetHumanizedRunningFromTime());
86 | }
87 | }
88 |
89 | return "???";
90 | }
91 | return string.Empty;
92 | }
93 |
94 | public static string ToBuildVerionString(this Project project)
95 | {
96 | if (project != null && !project.Builds.IsEmpty())
97 | {
98 | var build = project.Builds.First();
99 | return build.Version;
100 | }
101 | return null;
102 | }
103 |
104 | public static string ToCommitIdString(this Project project)
105 | {
106 | if (project != null && !project.Builds.IsEmpty())
107 | {
108 | var build = project.Builds.First();
109 | return build.CommitId;
110 | }
111 | return null;
112 | }
113 | }
114 | }
115 |
--------------------------------------------------------------------------------
/AppVeyor.Common/Extensions/ServiceProviderExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace AppVeyor.Common.Extensions
4 | {
5 | public static class ServiceProviderExtensions
6 | {
7 | ///
8 | /// Gets the service.
9 | ///
10 | /// The type of the service.
11 | /// The service provider.
12 | ///
13 | public static TService GetService(this IServiceProvider serviceProvider)
14 | {
15 | return (TService)serviceProvider.GetService(typeof(TService));
16 | }
17 |
18 | ///
19 | /// Gets the service.
20 | ///
21 | /// The type of the interface.
22 | /// The type of the interface.
23 | /// The service provider.
24 | ///
25 | public static TInterface GetService(this IServiceProvider serviceProvider)
26 | {
27 | return (TInterface)serviceProvider.GetService(typeof(SInterface));
28 | }
29 |
30 | ///
31 | /// Tries to the get service.
32 | ///
33 | /// The type of the service.
34 | /// The service provider.
35 | ///
36 | public static TService TryGetService(this IServiceProvider serviceProvider)
37 | {
38 | object service = serviceProvider.GetService(typeof(TService));
39 |
40 | if (service == null)
41 | {
42 | return default(TService);
43 | }
44 |
45 | return (TService)service;
46 | }
47 |
48 | ///
49 | /// Tries to the get service.
50 | ///
51 | /// The type of the interface.
52 | /// The type of the interface.
53 | /// The service provider.
54 | ///
55 | public static TInterface TryGetService(this IServiceProvider serviceProvider)
56 | {
57 | object service = serviceProvider.GetService(typeof(SInterface));
58 |
59 | if (service == null)
60 | {
61 | return default(TInterface);
62 | }
63 |
64 | return (TInterface)service;
65 | }
66 | }
67 | }
--------------------------------------------------------------------------------
/AppVeyor.Common/Extensions/StringExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace AppVeyor.Common.Extensions
4 | {
5 | public static class StringExtensions
6 | {
7 | public static bool EqualsIgnoreCase(this string input1, string input2)
8 | {
9 | return input1.Equals(input2, StringComparison.InvariantCultureIgnoreCase);
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/AppVeyor.Common/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.InteropServices;
3 |
4 | // General Information about an assembly is controlled through the following
5 | // set of attributes. Change these attribute values to modify the information
6 | // associated with an assembly.
7 | [assembly: AssemblyTitle("AppVeyor.Common")]
8 | [assembly: AssemblyDescription("")]
9 | [assembly: AssemblyConfiguration("")]
10 | [assembly: AssemblyCompany("")]
11 | [assembly: AssemblyProduct("AppVeyor.Common")]
12 | [assembly: AssemblyCopyright("Copyright © 2015")]
13 | [assembly: AssemblyTrademark("")]
14 | [assembly: AssemblyCulture("")]
15 |
16 | // Setting ComVisible to false makes the types in this assembly not visible
17 | // to COM components. If you need to access a type in this assembly from
18 | // COM, set the ComVisible attribute to true on that type.
19 | [assembly: ComVisible(false)]
20 |
21 | // The following GUID is for the ID of the typelib if this project is exposed to COM
22 | [assembly: Guid("3b8f7ac4-60a3-4087-a4dc-9471af441b93")]
23 |
24 | // Version information for an assembly consists of the following four values:
25 | //
26 | // Major Version
27 | // Minor Version
28 | // Build Number
29 | // Revision
30 | //
31 | // You can specify all the values or you can default the Build and Revision Numbers
32 | // by using the '*' as shown below:
33 | // [assembly: AssemblyVersion("1.0.*")]
34 | [assembly: AssemblyVersion("1.0.0.0")]
35 | [assembly: AssemblyFileVersion("1.0.0.0")]
36 |
--------------------------------------------------------------------------------
/AppVeyor.Common/Telemetry.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Microsoft.ApplicationInsights;
3 | using Microsoft.ApplicationInsights.Extensibility;
4 |
5 | namespace AppVeyor.Common
6 | {
7 | public class Telemetry
8 | {
9 | private static readonly TelemetryClient _telemetryClient = new TelemetryClient();
10 | // Explicit static constructor to tell C# compiler not to mark type as beforefieldinit
11 | static Telemetry()
12 | {
13 | #if DEBUG
14 | TelemetryConfiguration.Active.TelemetryChannel.DeveloperMode = true;
15 | #endif
16 | _telemetryClient.InstrumentationKey = "NA";
17 | _telemetryClient.Context.InstrumentationKey = "NA";
18 | _telemetryClient.Context.Session.Id = Guid.NewGuid().ToString();
19 | _telemetryClient.Context.User.AccountId = string.Format("{0}\\{1}", Environment.UserDomainName, Environment.UserName);
20 | _telemetryClient.Context.Device.OperatingSystem = Environment.OSVersion.ToString();
21 | _telemetryClient.Context.Device.Language = System.Threading.Thread.CurrentThread.CurrentCulture.Name;
22 | _telemetryClient.Context.Properties["AppVeyor Extension Version"] = "1.1";
23 |
24 | TelemetryConfiguration.Active.DisableTelemetry = true;
25 | }
26 |
27 | private Telemetry()
28 | {
29 | }
30 |
31 | public static TelemetryClient Instance
32 | {
33 | get { return _telemetryClient; }
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/AppVeyor.Common/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/AppVeyor.Package/AppVeyor.Package.cs:
--------------------------------------------------------------------------------
1 | namespace AppVeyor
2 | {
3 | using System;
4 |
5 | ///
6 | /// Helper class that exposes all GUIDs used across VS Package.
7 | ///
8 | internal sealed partial class GuidList
9 | {
10 | public const string guidAppVeyor_PackagePkgString = "a709c9b4-8b21-492f-aaa1-ed045db35043";
11 | public const string guidAppVeyor_PackageCmdSetString = "6cb5e405-3793-4a69-8acd-95c5f5f25df0";
12 | public const string guidShowAppVeyorWindowString = "6f6a1551-07cb-488c-835e-9c8a594e4c31";
13 | public const string guidShowProjectsTabString = "8a9536df-ec50-45ff-82dd-3c489480b27b";
14 | public const string guidShowUsersTabString = "5dc028a9-c7cf-494e-8d8b-c3729c4ed9ab";
15 | public const string guidShowEnvironmentsTabString = "855be23b-63f4-4212-8b6f-70afe1b309dc";
16 | public const string guidShowOptionsString = "eff56f04-9785-4b17-acee-00f8b8915308";
17 | public const string guidShowRefreshString = "6f3c0d89-2a18-48e3-9a55-041cb7ef7899";
18 | public const string guidImagesString = "e2abc2ed-f84b-4ce5-97b0-d393ba728b27";
19 | public static Guid guidAppVeyor_PackagePkg = new Guid(guidAppVeyor_PackagePkgString);
20 | public static Guid guidAppVeyor_PackageCmdSet = new Guid(guidAppVeyor_PackageCmdSetString);
21 | public static Guid guidShowAppVeyorWindow = new Guid(guidShowAppVeyorWindowString);
22 | public static Guid guidShowProjectsTab = new Guid(guidShowProjectsTabString);
23 | public static Guid guidShowUsersTab = new Guid(guidShowUsersTabString);
24 | public static Guid guidShowEnvironmentsTab = new Guid(guidShowEnvironmentsTabString);
25 | public static Guid guidShowOptions = new Guid(guidShowOptionsString);
26 | public static Guid guidShowRefresh = new Guid(guidShowRefreshString);
27 | public static Guid guidImages = new Guid(guidImagesString);
28 | }
29 | ///
30 | /// Helper class that encapsulates all CommandIDs uses across VS Package.
31 | ///
32 | internal sealed partial class PackageCommands
33 | {
34 | public const int AppVeyorToolbar = 0x1000;
35 | public const int AppVeyorToolbarGroup = 0x1050;
36 | public const int cmdidMyDropDownCombo = 0x1100;
37 | public const int cmdidMyDropDownComboGetList = 0x1101;
38 | public const int cmdidShowAppVeyorWindow = 0x0100;
39 | public const int appVeyorMenuGroup = 0x1020;
40 | public const int cmdidShowProjectsTab = 0x1060;
41 | public const int cmdidShowUsersTab = 0x1070;
42 | public const int cmdidShowEnvironmentsTab = 0x1080;
43 | public const int cmdidShowOptions = 0x1090;
44 | public const int cmdidShowRefresh = 0x1100;
45 | public const int projectsIcon = 0x0001;
46 | public const int environmentsIcon = 0x0002;
47 | public const int usersIcon = 0x0003;
48 | public const int appVeyorIcon = 0x0004;
49 | public const int optionsIcon = 0x0005;
50 | public const int refreshIcon = 0x0006;
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/AppVeyor.Package/AppVeyor.Package.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 12.0
5 | 12.0
6 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)
7 | SAK
8 | SAK
9 | SAK
10 | SAK
11 | ..\
12 | True
13 |
14 |
15 |
16 | Debug
17 | AnyCPU
18 | 2.0
19 | {26B8C337-1C8B-49BC-A936-72FA2FDFC380}
20 | {82b43b9b-a64c-4715-b499-d71e9ca2bd60};{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
21 | Library
22 | Properties
23 | AppVeyor
24 | AppVeyor.Package
25 | false
26 | Key.snk
27 | v4.5
28 |
29 |
30 | true
31 | full
32 | false
33 | bin\Debug\
34 | DEBUG;TRACE
35 | prompt
36 | 4
37 | True
38 |
39 |
40 | pdbonly
41 | true
42 | bin\Release\
43 | TRACE
44 | prompt
45 | 4
46 | true
47 |
48 |
49 |
50 | ..\packages\Microsoft.ApplicationInsights.1.2.0\lib\net45\Microsoft.ApplicationInsights.dll
51 | True
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 | true
61 |
62 |
63 | true
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 | ..\packages\PostSharp.4.1.23\lib\net35-client\PostSharp.dll
72 | True
73 | True
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 | {80CC9F66-E7D8-4DDD-85B6-D9E6CD0E93E2}
90 | 8
91 | 0
92 | 0
93 | primary
94 | False
95 | False
96 |
97 |
98 | {26AD1324-4B7C-44BC-84F8-B86AED45729F}
99 | 10
100 | 0
101 | 0
102 | primary
103 | False
104 | False
105 |
106 |
107 | {1A31287A-4D7D-413E-8E32-3B374931BD89}
108 | 8
109 | 0
110 | 0
111 | primary
112 | False
113 | False
114 |
115 |
116 | {2CE2370E-D744-4936-A090-3FFFE667B0E1}
117 | 9
118 | 0
119 | 0
120 | primary
121 | False
122 | False
123 |
124 |
125 | {1CBA492E-7263-47BB-87FE-639000619B15}
126 | 8
127 | 0
128 | 0
129 | primary
130 | False
131 | False
132 |
133 |
134 | {00020430-0000-0000-C000-000000000046}
135 | 2
136 | 0
137 | 0
138 | primary
139 | False
140 | False
141 |
142 |
143 |
144 |
145 | True
146 | True
147 | AppVeyor.Package.vsct
148 |
149 |
150 |
151 |
152 |
153 |
154 | True
155 | True
156 | Resources.resx
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 | ResXFileCodeGenerator
168 | Resources.Designer.cs
169 | Designer
170 |
171 |
172 | true
173 | VSPackage
174 |
175 |
176 |
177 |
178 |
179 | Designer
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 | Menus.ctmenu
188 | Designer
189 | VsctGenerator
190 | AppVeyor.Package.cs
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 | true
200 |
201 |
202 |
203 |
204 | {1e4ac15d-7590-4a7d-9c1b-8b0cce9582fd}
205 | AppVeyor.Api
206 |
207 |
208 | {262035FB-98EC-4E05-ADEF-3A4104962E36}
209 | AppVeyor.Common
210 |
211 |
212 | {a46a3d53-9e7e-4aed-a7cf-c7ddaba83feb}
213 | AppVeyor.UI
214 |
215 |
216 |
217 | true
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
233 |
--------------------------------------------------------------------------------
/AppVeyor.Package/AppVeyor.Package.vsct:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
12 |
13 |
14 |
15 |
16 |
17 |
24 |
25 |
26 |
33 |
43 |
51 |
60 |
61 |
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 |
--------------------------------------------------------------------------------
/AppVeyor.Package/AppVeyorPackage.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel.Design;
4 | using System.Runtime.InteropServices;
5 | using AppVeyor.Common;
6 | using AppVeyor.Common.Extensions;
7 | using AppVeyor.UI.Options;
8 | using AppVeyor.UI.Services;
9 | using AppVeyor.UI.ToolWindows;
10 | using EnvDTE;
11 | using Microsoft.VisualStudio.Shell;
12 | using Constants = AppVeyor.UI.Common.Constants;
13 |
14 | namespace AppVeyor
15 | {
16 | [PackageRegistration(UseManagedResourcesOnly = true)]
17 | [InstalledProductRegistration("#110", "#112", "1.1", IconResourceID = 400)]
18 | [ProvideMenuResource("Menus.ctmenu", 1)]
19 | [ProvideToolWindow(typeof(AppVeyorWindow))]
20 | [Guid(GuidList.guidAppVeyor_PackagePkgString)]
21 | [ProvideOptionPage(typeof(AppVeyorOptions), Constants.EXTENSION_NAME, "General", 0, 0, true)]
22 | [ProvideService(typeof(SEventManager))]
23 | [ProvideService(typeof(SCommandManagerService))]
24 | [ProvideBindingPath]
25 | public sealed class AppVeyorPackage : Package
26 | {
27 | private AppVeyorWindow _appVeyorToolWindow;
28 |
29 | public ToolWindowPane ToolWindow
30 | {
31 | get
32 | {
33 | if (_appVeyorToolWindow == null)
34 | {
35 | Telemetry.Instance.TrackEvent("Find AppVeyor ToolWindow");
36 | _appVeyorToolWindow = FindToolWindow(typeof(AppVeyorWindow), 0, true) as AppVeyorWindow;
37 | }
38 |
39 | return _appVeyorToolWindow;
40 | }
41 | }
42 |
43 | protected override void Initialize()
44 | {
45 | var dte = this.GetService();
46 | var version = dte.Version;
47 | base.Initialize();
48 | var properties = new Dictionary();
49 | properties["Visual Studio Version"] = string.Format("{0} {1}", version, dte.Edition) ;
50 |
51 |
52 | IServiceContainer serviceContainer = this;
53 | ServiceCreatorCallback creationCallback = CreateService;
54 | serviceContainer.AddService(typeof(SCommandManagerService), creationCallback, true);
55 | serviceContainer.AddService(typeof(SEventManager), creationCallback, true);
56 |
57 | var options = GetDialogPage(typeof (AppVeyorOptions)) as AppVeyorOptions;
58 | if (options != null)
59 | {
60 | var eventManager = this.GetService();
61 | eventManager.AppVeyorOptions = options;
62 | }
63 | CommandSet commandSet = new CommandSet(this);
64 | commandSet.Initialize();
65 |
66 | Telemetry.Instance.TrackEvent("Extension initialized", properties);
67 | }
68 |
69 | private object CreateService(IServiceContainer container, Type serviceType)
70 | {
71 | if (container != this)
72 | {
73 | return null;
74 | }
75 |
76 | if (typeof(SCommandManagerService) == serviceType)
77 | {
78 | return new CommandManagerServiceService(this);
79 | }
80 | if (typeof(SEventManager) == serviceType)
81 | {
82 | return new EventManagerService(this);
83 | }
84 |
85 | return null;
86 | }
87 | }
88 | }
--------------------------------------------------------------------------------
/AppVeyor.Package/CommandSet.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ComponentModel.Design;
3 | using AppVeyor.Commands;
4 | using Microsoft.VisualStudio.Shell;
5 | using AppVeyor.Common.Extensions;
6 | using AppVeyor.UI.Services;
7 |
8 | namespace AppVeyor
9 | {
10 | public class CommandSet
11 | {
12 | private IServiceProvider _serviceProvider;
13 | private OleMenuCommandService _menuCommandService;
14 |
15 | public CommandSet(IServiceProvider serviceProvider)
16 | {
17 | _serviceProvider = serviceProvider;
18 | _menuCommandService = _serviceProvider.GetService();
19 | }
20 | public void Initialize()
21 | {
22 | RegisterMenuCommands();
23 | }
24 |
25 | private void RegisterMenuCommands()
26 | {
27 | ICommandManagerService commandManager = _serviceProvider.GetService();
28 |
29 | var showAppVeyorWindowCommand = new ShowAppVeyorWindowCommand(_serviceProvider);
30 | _menuCommandService.AddCommand(showAppVeyorWindowCommand);
31 | commandManager.RegisterCommand(showAppVeyorWindowCommand);
32 |
33 | var showOptionsCommand = new ShowOptionsCommand(_serviceProvider);
34 | _menuCommandService.AddCommand(showOptionsCommand);
35 | commandManager.RegisterCommand(showOptionsCommand);
36 |
37 | var refrshCommand = new RefreshCommand(_serviceProvider);
38 | _menuCommandService.AddCommand(refrshCommand);
39 | commandManager.RegisterCommand(refrshCommand);
40 |
41 | }
42 | }
43 | }
--------------------------------------------------------------------------------
/AppVeyor.Package/Commands/Base/DynamicCommand.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ComponentModel.Design;
3 | using Microsoft.VisualStudio.Shell;
4 | using AppVeyor.Common.Extensions;
5 |
6 | namespace AppVeyor.Commands.Base
7 | {
8 | public abstract class DynamicCommand : OleMenuCommand
9 | {
10 | #region Fields
11 | private static IServiceProvider _serviceServiceProvider;
12 | private static AppVeyorPackage _appVeyorPackage;
13 |
14 | #endregion
15 |
16 | #region Properties
17 | ///
18 | /// The ServiceProvider
19 | ///
20 | protected static IServiceProvider ServiceProvider
21 | {
22 | get
23 | {
24 | return _serviceServiceProvider;
25 | }
26 | }
27 |
28 | #endregion
29 |
30 | #region Constructors
31 | ///
32 | /// Initializes a new instance of the class.
33 | ///
34 | /// The service provider.
35 | /// The on execute delegate.
36 | /// The command id.
37 | public DynamicCommand(IServiceProvider serviceProvider, EventHandler onExecute, CommandID id)
38 | : base(onExecute, id)
39 | {
40 | BeforeQueryStatus += new EventHandler(OnBeforeQueryStatus);
41 | _serviceServiceProvider = serviceProvider;
42 | }
43 | #endregion
44 |
45 | #region Protected Implementation
46 | ///
47 | /// Called when [before query status].
48 | ///
49 | /// The sender.
50 | /// The instance containing the event data.
51 | protected void OnBeforeQueryStatus(object sender, EventArgs e)
52 | {
53 | OleMenuCommand command = sender as OleMenuCommand;
54 |
55 | command.Enabled = command.Supported = CanExecute(command);
56 | }
57 |
58 | ///
59 | /// Determines whether this instance can execute the specified command.
60 | ///
61 | /// The command.
62 | ///
63 | /// true if this instance can execute the specified command; otherwise, false.
64 | ///
65 | protected virtual bool CanExecute(OleMenuCommand command)
66 | {
67 | return true;
68 | }
69 | #endregion
70 |
71 | protected static AppVeyorPackage AppVeyorPackage
72 | {
73 | get
74 | {
75 | if (_appVeyorPackage == null)
76 | {
77 | _appVeyorPackage = ServiceProvider.GetService();
78 | }
79 |
80 | return _appVeyorPackage;
81 | }
82 | }
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/AppVeyor.Package/Commands/ContextChangedCommand.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ComponentModel.Design;
3 | using System.Runtime.InteropServices;
4 | using AppVeyor.Commands.Base;
5 |
6 | namespace AppVeyor.Commands
7 | {
8 | [Guid("6cb5e405-3793-4a69-8acd-95c5f5f25df0")]
9 | public class ContextChangedCommand : DynamicCommand
10 | {
11 | public const uint cmdidMyDropDownCombo = 0x2910;
12 | public ContextChangedCommand(IServiceProvider serviceProvider)
13 | : base(
14 | serviceProvider,
15 | OnExecute,
16 | new CommandID(
17 | typeof(ContextChangedCommand).GUID,
18 | (int)cmdidMyDropDownCombo))
19 | {
20 | }
21 |
22 | private static void OnExecute(object sender, EventArgs e)
23 | {
24 |
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/AppVeyor.Package/Commands/RefreshCommand.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ComponentModel.Design;
3 | using AppVeyor.Commands.Base;
4 | using AppVeyor.Common.Extensions;
5 | using AppVeyor.UI.Services;
6 | using Microsoft.VisualStudio.Shell;
7 |
8 | namespace AppVeyor.Commands
9 | {
10 | public class RefreshCommand : DynamicCommand
11 | {
12 | private static IServiceProvider _serviceProvider;
13 |
14 | public RefreshCommand(IServiceProvider serviceProvider) :
15 | base(serviceProvider, OnExecute, new CommandID(GuidList.guidShowRefresh,
16 | PackageCommands.cmdidShowRefresh))
17 | {
18 | _serviceProvider = serviceProvider;
19 | }
20 |
21 | protected override bool CanExecute(OleMenuCommand command)
22 | {
23 | return true;
24 | }
25 |
26 | private static void OnExecute(object sender, EventArgs e)
27 | {
28 | var eventManager = _serviceProvider.GetService();
29 | eventManager.RefreshTriggerred();
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/AppVeyor.Package/Commands/ShowAppVeyorWindowCommand.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ComponentModel.Design;
3 | using System.Runtime.InteropServices;
4 | using System.Windows;
5 | using AppVeyor.Commands.Base;
6 | using AppVeyor.Common;
7 | using Microsoft.VisualStudio;
8 | using Microsoft.VisualStudio.Shell;
9 | using Microsoft.VisualStudio.Shell.Interop;
10 |
11 | namespace AppVeyor.Commands
12 | {
13 | public class ShowAppVeyorWindowCommand : DynamicCommand
14 | {
15 | public ShowAppVeyorWindowCommand(IServiceProvider serviceProvider)
16 | : base(serviceProvider, OnExecute, new CommandID(GuidList.guidShowAppVeyorWindow,
17 | PackageCommands.cmdidShowAppVeyorWindow))
18 | {
19 | }
20 |
21 | protected override bool CanExecute(OleMenuCommand command)
22 | {
23 | return true;
24 | }
25 |
26 | private static void OnExecute(object sender, EventArgs e)
27 | {
28 | try
29 | {
30 | ToolWindowPane window = AppVeyorPackage.ToolWindow;
31 | if ((window == null) || (window.Frame == null))
32 | {
33 | throw new COMException("Cannot create toolwindow");
34 | }
35 |
36 | IVsWindowFrame windowFrame = (IVsWindowFrame)window.Frame;
37 | ErrorHandler.ThrowOnFailure(windowFrame.Show());
38 | Telemetry.Instance.TrackEvent("Toolwindow opened from menu");
39 | }
40 | catch (Exception exception)
41 | {
42 | Telemetry.Instance.TrackException(exception);
43 | MessageBox.Show("Sorry, Unable to open AppVeyor window.", "AppVeyor Extension for Visual Studio",
44 | MessageBoxButton.OK, MessageBoxImage.Warning);
45 | }
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/AppVeyor.Package/Commands/ShowOptionsCommand.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ComponentModel.Design;
3 | using AppVeyor.Commands.Base;
4 | using AppVeyor.Common;
5 | using AppVeyor.UI.Options;
6 | using Microsoft.VisualStudio.Shell;
7 |
8 | namespace AppVeyor.Commands
9 | {
10 | public class ShowOptionsCommand : DynamicCommand
11 | {
12 | public ShowOptionsCommand(IServiceProvider serviceProvider)
13 | : base(serviceProvider, OnExecute, new CommandID(GuidList.guidShowOptions, PackageCommands.cmdidShowOptions))
14 | {
15 | }
16 |
17 | protected override bool CanExecute(OleMenuCommand command)
18 | {
19 | return true;
20 | }
21 | private static void OnExecute(object sender, EventArgs e)
22 | {
23 | Telemetry.Instance.TrackEvent("Options page opened");
24 | AppVeyorPackage.ShowOptionPage(typeof(AppVeyorOptions));
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/AppVeyor.Package/GlobalSuppressions.cs:
--------------------------------------------------------------------------------
1 | // This file is used by Code Analysis to maintain SuppressMessage
2 | // attributes that are applied to this project. Project-level
3 | // suppressions either have no target or are given a specific target
4 | // and scoped to a namespace, type, member, etc.
5 | //
6 | // To add a suppression to this file, right-click the message in the
7 | // Error List, point to "Suppress Message(s)", and click "In Project
8 | // Suppression File". You do not need to add suppressions to this
9 | // file manually.
10 |
11 | [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1017:MarkAssembliesWithComVisible")]
12 |
--------------------------------------------------------------------------------
/AppVeyor.Package/Key.snk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/onlyutkarsh/AppVeyorExtension/761b9625a94febc68aa92f368716be488afabb77/AppVeyor.Package/Key.snk
--------------------------------------------------------------------------------
/AppVeyor.Package/PkgCmdID.cs:
--------------------------------------------------------------------------------
1 | // PkgCmdID.cs
2 | // MUST match PkgCmdID.h
3 |
4 | namespace AppVeyor
5 | {
6 | static class PkgCmdIDList
7 | {
8 | public static uint cmdidMyDropDownCombo = 0x1090;
9 | public static uint cmdidMyDropDownComboGetList = 0x1200;
10 | public const uint cmdidViewAppVeyor = 0x100;
11 | public const uint cmdidAppVeyor = 0x101;
12 | public const uint AppVeyorToolbar = 0x1000;
13 |
14 | public const uint cmdidProjectsAndBuilds = 0x1060;
15 | public const uint cmdidTeamsAndUsers = 0x1070;
16 | public const uint cmdidEnvironmentsAndDeployments = 0x1080;
17 | };
18 | }
--------------------------------------------------------------------------------
/AppVeyor.Package/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Reflection;
3 | using System.Resources;
4 | using System.Runtime.InteropServices;
5 |
6 | // General Information about an assembly is controlled through the following
7 | // set of attributes. Change these attribute values to modify the information
8 | // associated with an assembly.
9 | [assembly: AssemblyTitle("AppVeyorPackage")]
10 | [assembly: AssemblyDescription("")]
11 | [assembly: AssemblyConfiguration("")]
12 | [assembly: AssemblyCompany("Utkarsh Shigihalli & Tarun Arora")]
13 | [assembly: AssemblyProduct("AppVeyorPackage")]
14 | [assembly: AssemblyCopyright("")]
15 | [assembly: AssemblyTrademark("")]
16 | [assembly: AssemblyCulture("")]
17 | [assembly: ComVisible(false)]
18 | [assembly: CLSCompliant(false)]
19 | [assembly: NeutralResourcesLanguage("en-US")]
20 |
21 | // Version information for an assembly consists of the following four values:
22 | //
23 | // Major Version
24 | // Minor Version
25 | // Build Number
26 | // Revision
27 | //
28 | // You can specify all the values or you can default the Revision and Build Numbers
29 | // by using the '*' as shown below:
30 |
31 | [assembly: AssemblyVersion("1.0.0.0")]
32 | [assembly: AssemblyFileVersion("1.0.0.0")]
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/AppVeyor.Package/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 AppVeyor {
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", "4.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("AppVeyor.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 Can not create tool window..
65 | ///
66 | internal static string CanNotCreateWindow {
67 | get {
68 | return ResourceManager.GetString("CanNotCreateWindow", resourceCulture);
69 | }
70 | }
71 |
72 | ///
73 | /// Looks up a localized string similar to AppVeyor Extension for Visual Studio.
74 | ///
75 | internal static string ToolWindowTitle {
76 | get {
77 | return ResourceManager.GetString("ToolWindowTitle", resourceCulture);
78 | }
79 | }
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/AppVeyor.Package/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 | Can not create tool window.
122 |
123 |
124 | AppVeyor Extension for Visual Studio
125 |
126 |
--------------------------------------------------------------------------------
/AppVeyor.Package/Resources/AppVeyorToolbar.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/onlyutkarsh/AppVeyorExtension/761b9625a94febc68aa92f368716be488afabb77/AppVeyor.Package/Resources/AppVeyorToolbar.png
--------------------------------------------------------------------------------
/AppVeyor.Package/Resources/Images.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/onlyutkarsh/AppVeyorExtension/761b9625a94febc68aa92f368716be488afabb77/AppVeyor.Package/Resources/Images.png
--------------------------------------------------------------------------------
/AppVeyor.Package/Resources/Package.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/onlyutkarsh/AppVeyorExtension/761b9625a94febc68aa92f368716be488afabb77/AppVeyor.Package/Resources/Package.ico
--------------------------------------------------------------------------------
/AppVeyor.Package/VSPackage.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 | AppVeyor Extension for Visual Studio
122 |
123 |
124 | Manage your AppVeyor builds from Visual Studio
125 |
126 |
127 |
128 | Resources\Package.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
129 |
130 |
131 | Resources\Images.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
132 |
133 |
--------------------------------------------------------------------------------
/AppVeyor.Package/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/AppVeyor.Package/source.extension.vsixmanifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | AppVeyor Extension for Visual Studio
5 | Utkarsh Shigihalli & Tarun Arora
6 | 1.1
7 | Manage your AppVeyor builds from Visual Studio.
8 | 1033
9 | Resources\Package.ico
10 |
11 |
12 |
13 | Ultimate
14 | Premium
15 | Pro
16 | IntegratedShell
17 |
18 |
19 | Ultimate
20 | Premium
21 | Pro
22 | IntegratedShell
23 |
24 |
25 |
26 |
27 |
28 | |%CurrentProject%;PkgdefProjectOutputGroup|
29 | |%CurrentProject%|
30 | |AppVeyor.UI|
31 |
32 |
--------------------------------------------------------------------------------
/AppVeyor.UI/AppVeyor.UI.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {A46A3D53-9E7E-4AED-A7CF-C7DDABA83FEB}
8 | Library
9 | Properties
10 | AppVeyor.UI
11 | AppVeyor.UI
12 | v4.5
13 | 512
14 | SAK
15 | SAK
16 | SAK
17 | SAK
18 | ..\
19 | True
20 |
21 |
22 | true
23 | full
24 | false
25 | bin\Debug\
26 | DEBUG;TRACE
27 | prompt
28 | 4
29 | true
30 |
31 |
32 | pdbonly
33 | true
34 | bin\Release\
35 | TRACE
36 | prompt
37 | 4
38 |
39 |
40 | false
41 |
42 |
43 | Key.snk
44 |
45 |
46 | false
47 |
48 |
49 |
50 | ..\packages\CuttingEdge.Conditions.1.2.0.0\lib\NET35\CuttingEdge.Conditions.dll
51 | True
52 |
53 |
54 | ..\packages\Microsoft.ApplicationInsights.1.2.0\lib\net45\Microsoft.ApplicationInsights.dll
55 | True
56 |
57 |
58 |
59 |
60 |
61 | True
62 |
63 |
64 | True
65 |
66 |
67 |
68 |
69 | ..\packages\Ookii.Dialogs.1.0\lib\net35\Ookii.Dialogs.Wpf.dll
70 | True
71 |
72 |
73 | ..\packages\PostSharp.4.1.23\lib\net35-client\PostSharp.dll
74 | True
75 | True
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 | False
89 | ..\..\_Dependencies\System.Windows.Interactivity.dll
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 | ClosableHeader.xaml
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 | Component
136 |
137 |
138 | AppVeyorOptions.cs
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 | AppVeyorWindowContent.xaml
151 |
152 |
153 |
154 |
155 |
156 | MSBuild:Compile
157 | Designer
158 |
159 |
160 | MSBuild:Compile
161 | Designer
162 |
163 |
164 |
165 |
166 |
167 | Designer
168 |
169 |
170 |
171 |
172 | {1e4ac15d-7590-4a7d-9c1b-8b0cce9582fd}
173 | AppVeyor.Api
174 |
175 |
176 | {262035fb-98ec-4e05-adef-3a4104962e36}
177 | AppVeyor.Common
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
205 |
--------------------------------------------------------------------------------
/AppVeyor.UI/Aspects/HandleException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using AppVeyor.Common;
4 | using AppVeyor.UI.ViewModel;
5 | using PostSharp.Aspects;
6 |
7 | namespace AppVeyor.UI.Aspects
8 | {
9 | [Serializable]
10 | public sealed class HandleException : OnMethodBoundaryAspect
11 | {
12 | public HandleException(bool isAsync = true)
13 | {
14 | ApplyToStateMachine = isAsync;
15 | }
16 |
17 | public override void OnException(MethodExecutionArgs args)
18 | {
19 | var properties = new Dictionary()
20 | {
21 | {"Method Name", args.Method.Name}
22 | };
23 | Telemetry.Instance.TrackException(args.Exception, properties);
24 | AppVeyorWindowViewModel.Instance.AddAlert(args.Exception, args.Exception.Message);
25 | base.OnException(args);
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/AppVeyor.UI/BindinError/BindingTraceListener.cs:
--------------------------------------------------------------------------------
1 | using System.Diagnostics;
2 | using System.Text;
3 | using System.Windows;
4 |
5 | namespace AppVeyor.UI.BindinError
6 | {
7 | public class BindingErrorTraceListener : DefaultTraceListener
8 | {
9 | private static BindingErrorTraceListener _listener;
10 |
11 | public static void SetTrace()
12 | { SetTrace(SourceLevels.Error, TraceOptions.None); }
13 |
14 | public static void SetTrace(SourceLevels level, TraceOptions options)
15 | {
16 | if (_listener == null)
17 | {
18 | _listener = new BindingErrorTraceListener();
19 | PresentationTraceSources.DataBindingSource.Listeners.Add(_listener);
20 | }
21 |
22 | _listener.TraceOutputOptions = options;
23 | PresentationTraceSources.DataBindingSource.Switch.Level = level;
24 | }
25 |
26 | public static void CloseTrace()
27 | {
28 | if (_listener == null)
29 | { return; }
30 |
31 | _listener.Flush();
32 | _listener.Close();
33 | PresentationTraceSources.DataBindingSource.Listeners.Remove(_listener);
34 | _listener = null;
35 | }
36 |
37 |
38 |
39 | private StringBuilder _Message = new StringBuilder();
40 |
41 | private BindingErrorTraceListener()
42 | { }
43 |
44 | public override void Write(string message)
45 | { _Message.Append(message); }
46 |
47 | public override void WriteLine(string message)
48 | {
49 | _Message.Append(message);
50 |
51 | var final = _Message.ToString();
52 | _Message.Length = 0;
53 |
54 | MessageBox.Show(final, "Binding Error", MessageBoxButton.OK,
55 | MessageBoxImage.Error);
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/AppVeyor.UI/Common/Constants.cs:
--------------------------------------------------------------------------------
1 | namespace AppVeyor.UI.Common
2 | {
3 | public class Constants
4 | {
5 | public const string PROJECTS = "Projects";
6 | public const string USERS = "Users";
7 | public const string ENVIRONMENTS = "Environments";
8 | public const string EXTENSION_NAME = "AppVeyor";
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/AppVeyor.UI/Common/DataContextSpy.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ComponentModel;
3 | using System.Windows;
4 | using System.Windows.Data;
5 |
6 | namespace AppVeyor.UI.Common
7 | {
8 | public class DataContextSpy : Freezable // Enable ElementName and DataContext bindings
9 | {
10 | public DataContextSpy()
11 | {
12 | // This binding allows the spy to inherit a DataContext.
13 | BindingOperations.SetBinding(this, DataContextProperty, new Binding());
14 |
15 | this.IsSynchronizedWithCurrentItem = true;
16 | }
17 |
18 | ///
19 | /// Gets/sets whether the spy will return the CurrentItem of the
20 | /// ICollectionView that wraps the data context, assuming it is
21 | /// a collection of some sort. If the data context is not a
22 | /// collection, this property has no effect.
23 | /// The default value is true.
24 | ///
25 | public bool IsSynchronizedWithCurrentItem { get; set; }
26 |
27 | public object DataContext
28 | {
29 | get { return (object)GetValue(DataContextProperty); }
30 | set { SetValue(DataContextProperty, value); }
31 | }
32 |
33 | // Borrow the DataContext dependency property from FrameworkElement.
34 | public static readonly DependencyProperty DataContextProperty =
35 | FrameworkElement.DataContextProperty.AddOwner(
36 | typeof(DataContextSpy),
37 | new PropertyMetadata(null, null, OnCoerceDataContext));
38 |
39 | static object OnCoerceDataContext(DependencyObject depObj, object value)
40 | {
41 | DataContextSpy spy = depObj as DataContextSpy;
42 | if (spy == null)
43 | return value;
44 |
45 | if (spy.IsSynchronizedWithCurrentItem)
46 | {
47 | ICollectionView view = CollectionViewSource.GetDefaultView(value);
48 | if (view != null)
49 | return view.CurrentItem;
50 | }
51 |
52 | return value;
53 | }
54 |
55 | protected override Freezable CreateInstanceCore()
56 | {
57 | // We are required to override this abstract method.
58 | throw new NotImplementedException();
59 | }
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/AppVeyor.UI/Common/DropDownButton.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 | using System.Windows.Controls;
3 | using System.Windows.Controls.Primitives;
4 | using System.Windows.Data;
5 |
6 | namespace AppVeyor.UI.Common
7 | {
8 | public class DropDownButton : ToggleButton
9 | {
10 | // *** Dependency Properties ***
11 | public static readonly DependencyProperty DropDownProperty = DependencyProperty.Register("DropDown", typeof(ContextMenu), typeof(DropDownButton), new UIPropertyMetadata(null));
12 |
13 | // *** Constructors ***
14 | public DropDownButton()
15 | {
16 | // Bind the ToogleButton.IsChecked property to the drop-down's IsOpen property
17 |
18 | Binding binding = new Binding("DropDown.IsOpen");
19 | binding.Source = this;
20 | SetBinding(IsCheckedProperty, binding);
21 | }
22 |
23 | // *** Properties ***
24 | public ContextMenu DropDown
25 | {
26 | get
27 | {
28 | return (ContextMenu)GetValue(DropDownProperty);
29 | }
30 | set
31 | {
32 | SetValue(DropDownProperty, value);
33 | }
34 | }
35 |
36 | // *** Overridden Methods ***
37 | protected override void OnClick()
38 | {
39 | if (DropDown != null)
40 | {
41 | // If there is a drop-down assigned to this button, then position and display it
42 |
43 | DropDown.PlacementTarget = this;
44 | DropDown.Placement = PlacementMode.Bottom;
45 |
46 | DropDown.IsOpen = true;
47 | }
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/AppVeyor.UI/Common/Message.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace AppVeyor.UI.Common
4 | {
5 | public class Message
6 | {
7 | public DateTime TimeStamp { get; set; }
8 |
9 | public string Text { get; set; }
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/AppVeyor.UI/Common/PauseToken.cs:
--------------------------------------------------------------------------------
1 | using System.Diagnostics;
2 | using System.Threading.Tasks;
3 |
4 | namespace AppVeyor.UI.Common
5 | {
6 | public struct PauseToken
7 | {
8 | private readonly PauseTokenSource _source;
9 |
10 | internal PauseToken(PauseTokenSource source)
11 | {
12 | _source = source;
13 | }
14 |
15 | public bool IsPaused
16 | {
17 | get { return _source != null && _source.IsPaused; }
18 | }
19 |
20 | public Task WaitWhilePausedAsync()
21 | {
22 | if (IsPaused)
23 | {
24 | Debug.WriteLine("PAUSED...");
25 | return _source.WaitWhilePausedAsync();
26 | }
27 | else return PauseTokenSource._completedTask;
28 | }
29 | }
30 | }
--------------------------------------------------------------------------------
/AppVeyor.UI/Common/PauseTokenSource.cs:
--------------------------------------------------------------------------------
1 | using System.Threading;
2 | using System.Threading.Tasks;
3 |
4 | namespace AppVeyor.UI.Common
5 | {
6 | public class PauseTokenSource
7 | {
8 | private volatile TaskCompletionSource _paused;
9 | internal static readonly Task _completedTask = Task.FromResult(true);
10 | public PauseToken Token { get { return new PauseToken(this); } }
11 |
12 |
13 | public bool IsPaused
14 | {
15 | get { return _paused != null; }
16 | set
17 | {
18 | if (value)
19 | {
20 | //store it in a variable as a reference to a volatile field will not be treated as volatile
21 | var paused = _paused;
22 | Interlocked.CompareExchange(ref paused, new TaskCompletionSource(), null);
23 | }
24 | else
25 | {
26 | while (true)
27 | {
28 | var tcs = _paused;
29 | if (tcs == null) return;
30 | var paused = _paused;
31 | if (Interlocked.CompareExchange(ref paused, null, tcs) == tcs)
32 | {
33 | tcs.SetResult(true);
34 | break;
35 | }
36 | }
37 | }
38 | }
39 | }
40 |
41 | internal Task WaitWhilePausedAsync()
42 | {
43 | var cur = _paused;
44 | return cur != null ? cur.Task : _completedTask;
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/AppVeyor.UI/Common/ProjectComparer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using AppVeyor.Common.Entities;
5 |
6 | namespace AppVeyor.UI.Common
7 | {
8 | public class ProjectComparer : IEqualityComparer
9 | {
10 | public bool Equals(Project first, Project second)
11 | {
12 | if (ReferenceEquals(first, second))
13 | return true;
14 |
15 | if (ReferenceEquals(first, null) || ReferenceEquals(second, null))
16 | return false;
17 |
18 | var firstProjectBuild = first.Builds.First();
19 | var secondProjectBuild = second.Builds.First();
20 |
21 | var firstProjectBuildStatus = firstProjectBuild.Status.First();
22 | var secondProjectBuildStatus = secondProjectBuild.Status.First();
23 |
24 | if(firstProjectBuildStatus.Equals("queued", StringComparison.InvariantCultureIgnoreCase)
25 | || firstProjectBuildStatus.Equals("running", StringComparison.InvariantCultureIgnoreCase))
26 | {
27 | return false;
28 | }
29 |
30 | var buildStausEqual = (firstProjectBuildStatus
31 | .Equals(secondProjectBuildStatus, StringComparison.InvariantCultureIgnoreCase));
32 |
33 | var branchEqual = firstProjectBuild.Branch.Equals(secondProjectBuild.Branch,
34 | StringComparison.CurrentCultureIgnoreCase);
35 |
36 | var versionEqual = firstProjectBuild.Version.Equals(secondProjectBuild.Version,
37 | StringComparison.InvariantCultureIgnoreCase);
38 |
39 | var commitIdEqual = firstProjectBuild.CommitId.Equals(secondProjectBuild.CommitId,
40 | StringComparison.InvariantCultureIgnoreCase);
41 |
42 | var committerNameEqual = firstProjectBuild.CommitterName.Equals(secondProjectBuild.CommitterName,
43 | StringComparison.InvariantCultureIgnoreCase);
44 |
45 | var committedDateEqual = firstProjectBuild.Committed.Equals(secondProjectBuild.Committed,
46 | StringComparison.InvariantCultureIgnoreCase);
47 |
48 | var createdEqual = firstProjectBuild.Created.Equals(secondProjectBuild.Created,
49 | StringComparison.InvariantCultureIgnoreCase);
50 |
51 | return buildStausEqual && branchEqual && versionEqual && commitIdEqual && committerNameEqual && committedDateEqual
52 | && createdEqual;
53 | }
54 |
55 | public int GetHashCode(Project project)
56 | {
57 | if (ReferenceEquals(project, null))
58 | return 0;
59 |
60 | return project.GetHashCode();
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/AppVeyor.UI/Common/RelayCommand.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows.Input;
3 |
4 | namespace AppVeyor.UI.Common
5 | {
6 |
7 | //public class RelayCommand : ICommand
8 | //{
9 | // #region Fields
10 |
11 | // readonly Action