Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New project system & Cargo based build system #234

Merged
merged 33 commits into from
Oct 21, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
9fd25c3
Copy sources for file-system based project from RTVS
Boddlnagg Oct 1, 2016
708c1a2
First try at integrating new project system
Boddlnagg Oct 1, 2016
ccf0498
Disabled old project system and debugger integration
Boddlnagg Oct 1, 2016
d62364e
Fixed conflicting dependencies
Boddlnagg Oct 1, 2016
7636918
Project loading actually works (with correctly hacked project files ...)
Boddlnagg Oct 4, 2016
9dd6fc1
Trying to get icons working
Boddlnagg Oct 4, 2016
80b529b
Icons finally work
Boddlnagg Oct 5, 2016
f8f1c10
Add preliminary Cargo manifest icon
Boddlnagg Oct 5, 2016
21ebaa3
Include CPS Rules in MSBuild targets file
Boddlnagg Oct 5, 2016
ecca190
Add correct rsproj file generator
Boddlnagg Oct 5, 2016
f678c91
Moved CPS related files to ProjectSystem namespace
Boddlnagg Oct 6, 2016
7c65983
Update project templates
Boddlnagg Oct 6, 2016
47fd4c6
Fix missing build error messages (e.g. missing entry point file)
Boddlnagg Oct 6, 2016
e61bd53
Clean up project files and use VS NuGet packages from Microsoft
Boddlnagg Oct 6, 2016
1df6a94
Worked on debugger integration (currently disabled)
Boddlnagg Oct 7, 2016
2bd11b7
Move target rules to VisualRust project and enable <XamlPropertyRule>
Boddlnagg Oct 7, 2016
52910ed
Wrap cargo in MSBuild
Boddlnagg Oct 8, 2016
91061c3
Use correct binary file name for debugging
Boddlnagg Oct 8, 2016
0a62f93
Eliminate some warnings and fix typo
Boddlnagg Oct 8, 2016
e984dfe
Re-enable GDB support
Boddlnagg Oct 10, 2016
f1677d0
Use correct manifest path; re-enable "Go To Definition"
Boddlnagg Oct 10, 2016
9f1530c
Use correct global Debugging options
Boddlnagg Oct 11, 2016
4320a55
Remove old tests, update remaining ones
Boddlnagg Oct 11, 2016
d032ac2
Completely remove old project system
Boddlnagg Oct 11, 2016
ff4769f
Removed Debug-CI configuration
Boddlnagg Oct 11, 2016
cf26c4b
Remove previously missed files
Boddlnagg Oct 11, 2016
79fb6c1
Updated setup
Boddlnagg Oct 12, 2016
66b5d88
Updated version and README
Boddlnagg Oct 12, 2016
c10d907
Convert tabs to spaces
Boddlnagg Oct 14, 2016
1a2f8c9
Fix loading VisualRust when RTVS is installed
Boddlnagg Oct 15, 2016
b64875b
Updated imported code from RTVS
Boddlnagg Oct 19, 2016
18ed078
Merge branch 'rtvs-import' into projectsystem
Boddlnagg Oct 19, 2016
a41e41a
Changed namespace of FileSystemMirroring project
Boddlnagg Oct 19, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
7 changes: 7 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
; Top-most EditorConfig file
root = true

; 4-column space indentation
[*.cs]
indent_style = space
indent_size = 4
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*.suo
*.user
*.sln.docstates
.vs

# Build results

Expand Down Expand Up @@ -98,6 +99,9 @@ publish/
# NuGet Packages Directory
packages/

# NuGet lock files
project.lock.json

# Windows Azure Build Output
csx
*.build.csdef
Expand Down
38 changes: 38 additions & 0 deletions Microsoft.Common.Core/Collections/DictionaryExtension.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;

namespace Microsoft.Common.Core {
public static class DictionaryExtension {
public static IDictionary<string, object> FromAnonymousObject(object data) {
IDictionary<string, object> dict;
if (data != null) {
dict = data as IDictionary<string, object>;
if (dict == null) {
var attr = BindingFlags.Public | BindingFlags.Instance;
dict = new Dictionary<string, object>();
foreach (var property in data.GetType().GetProperties(attr)) {
if (property.CanRead) {
dict.Add(property.Name, property.GetValue(data, null));
}
}
}
}
else {
dict = new Dictionary<string, object>();
}
return dict;
}

public static void RemoveWhere<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, Func<KeyValuePair<TKey, TValue>, bool> predicate) {
var toRemove = dictionary.Where(predicate).ToList();
foreach (var item in toRemove) {
dictionary.Remove(item.Key);
}
}
}
}
113 changes: 113 additions & 0 deletions Microsoft.Common.Core/Collections/EnumerableExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

using System;
using System.Collections.Generic;
using System.Linq;

namespace Microsoft.Common.Core {
public static class EnumerableExtensions {
public static List<T> AsList<T>(this IEnumerable<T> source) {
return source as List<T> ?? source.ToList();
}

public static T[] AsArray<T>(this IEnumerable<T> source) {
return source as T[] ?? source.ToArray();
}

public static IEnumerable<T> Append<T>(this IEnumerable<T> source, T item) {
foreach (T sourceItem in source) {
yield return sourceItem;
}

yield return item;
}

public static void Split<T>(this IEnumerable<T> source, Func<T, bool> predicate, out IList<T> first, out IList<T> second) {
first = new List<T>();
second = new List<T>();
foreach (var item in source) {
if (predicate(item)) {
first.Add(item);
} else {
second.Add(item);
}
}
}

public static void Split<TIn, TOut>(this IEnumerable<TIn> source, Func<TIn, bool> predicate, Func<TIn, TOut> converter, out IList<TOut> first, out IList<TOut> second) {
first = new List<TOut>();
second = new List<TOut>();
foreach (var item in source) {
if (predicate(item)) {
first.Add(converter(item));
} else {
second.Add(converter(item));
}
}
}

public static IEnumerable<IReadOnlyCollection<T>> Split<T>(this IEnumerable<T> source, int chunkSize) {
var index = 0;
var items = new T[chunkSize];
foreach (var item in source) {
items[index] = item;
index++;

if (index == chunkSize) {
index = 0;
yield return items;
items = new T[chunkSize];
}
}

if (index > 0) {
T[] lastItems = new T[index];
Array.Copy(items, 0, lastItems, 0, lastItems.Length);
yield return lastItems;
}
}

public static IEnumerable<int> IndexWhere<T>(this IEnumerable<T> source, Func<T, bool> predicate) {
var i = 0;
foreach (var item in source) {
if (predicate(item)) {
yield return i;
}

i++;
}
}

public static IEnumerable<T> TraverseBreadthFirst<T>(this T root, Func<T, IEnumerable<T>> selectChildren) {
Queue<T> items = new Queue<T>();
items.Enqueue(root);
while (items.Count > 0) {
var item = items.Dequeue();
yield return item;

IEnumerable<T> childen = selectChildren(item);
if (childen == null) {
continue;
}

foreach (var child in childen) {
items.Enqueue(child);
}
}
}

public static IEnumerable<T> TraverseDepthFirst<T>(this T root, Func<T, IEnumerable<T>> selectChildren) {
yield return root;

var children = selectChildren(root);
if (children != null) {
foreach (T child in children) {
foreach (T t in TraverseDepthFirst(child, selectChildren)) {
yield return t;
}
}
}
}
}
}
76 changes: 76 additions & 0 deletions Microsoft.Common.Core/Collections/ListExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

using System;
using System.Collections.Generic;
using System.Linq;

namespace Microsoft.Common.Core.Collections {
public static class ListExtensions {
public static IList<T> AddIf<T>(this IList<T> list, bool condition, T value) {
if (condition) {
list.Add(value);
}

return list;
}

public static void RemoveWhere<T>(this IList<T> list, Func<T, bool> predicate) {
for (var i = list.Count - 1; i >= 0; i--) {
if (predicate(list[i])) {
list.RemoveAt(i);
}
}
}

public static bool AddSorted<T>(this IList<T> list, T value, IComparer<T> comparer = null) {
var index = list.BinarySearch(value, comparer);
if (index >= 0) {
return false;
}

list.Insert(~index, value);
return true;
}

public static bool RemoveSorted<T>(this IList<T> list, T value, IComparer<T> comparer = null) {
var index = list.BinarySearch(value, comparer);
if (index < 0) {
return false;
}

list.RemoveAt(index);
return true;
}

public static int BinarySearch<T>(this IList<T> list, T value, IComparer<T> comparer = null) {
if (list == null) {
throw new ArgumentNullException(nameof(list));
}

comparer = comparer ?? Comparer<T>.Default;

int low = 0;
int high = list.Count - 1;

while (low <= high) {
int mid = low + (high - low) / 2;
int comparisonResult = comparer.Compare(list[mid], value);

if (comparisonResult < 0) {
low = mid + 1;
} else if (comparisonResult > 0) {
high = mid - 1;
} else {
return mid;
}
}

return ~low;
}

public static bool Equals<T, TOther>(this IList<T> source, IList<TOther> other, Func<T, TOther, bool> predicate) {
return source.Count == other.Count && !source.Where((t, i) => !predicate(t, other[i])).Any();
}
}
}
8 changes: 8 additions & 0 deletions Microsoft.Common.Core/Composition/INamedExport.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

namespace Microsoft.Common.Core.Composition {
public interface INamedExport {
string Name { get; }
}
}
22 changes: 22 additions & 0 deletions Microsoft.Common.Core/Composition/NamedExportLocator.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Linq;

namespace Microsoft.Common.Core.Composition {
public sealed class NamedExportLocator<TExport> {
[ImportMany]
private IEnumerable<Lazy<TExport, INamedExport>> Exports { get; set; }

public NamedExportLocator(ICompositionService cs) {
cs.SatisfyImportsOnce(this);
}

public TExport GetExport(string name) {
return Exports.FirstOrDefault(e => e.Metadata.Name.EqualsOrdinal(name)).Value;
}
}
}
34 changes: 34 additions & 0 deletions Microsoft.Common.Core/Diagnostics/Check.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

using System;

namespace Microsoft.Common.Core.Diagnostics {
public static class Check {
public static void ArgumentNull(string argumentName, object argument) {
if (argument == null) {
throw new ArgumentNullException(argumentName);
}
}

public static void ArgumentStringNullOrEmpty(string argumentName, string argument) {
Check.ArgumentNull(argumentName, argument);

if (string.IsNullOrEmpty(argument)) {
throw new ArgumentException(argumentName);
}
}

public static void ArgumentOutOfRange(string argumentName, Func<bool> predicate) {
if (predicate()) {
throw new ArgumentOutOfRangeException(argumentName);
}
}

public static void InvalidOperation(Func<bool> predicate) {
if (predicate()) {
throw new InvalidOperationException();
}
}
}
}
Loading