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

Annotate most of Microsoft.VisualStudio.ProjectSystem.Managed #5003

Merged
merged 14 commits into from
Jul 11, 2019
2 changes: 1 addition & 1 deletion build/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<VSWhereVersion>2.3.2</VSWhereVersion>
<TRXUnitVersion>1.0.0-beta1</TRXUnitVersion>
<MicrosoftDotNetIBCMergeVersion>4.7.1-alpha-00001</MicrosoftDotNetIBCMergeVersion>
<MicrosoftNetCompilersVersion>3.3.0-beta1-19327-04</MicrosoftNetCompilersVersion>
<MicrosoftNetCompilersVersion>3.3.0-beta2-19357-02</MicrosoftNetCompilersVersion>
<MicrosoftDiaSymReaderPdb2PdbVersion>1.1.0-beta1-62624-01</MicrosoftDiaSymReaderPdb2PdbVersion>
<RoslynAnalyzersPackagesVersion>2.9.3</RoslynAnalyzersPackagesVersion>
<RoslynAnalyzersOldPackagesVersion>2.6.3-beta1.19059.2</RoslynAnalyzersOldPackagesVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,17 @@ public WaitIndicatorResult WaitWithResult(string title, string message, bool all
}
catch (OperationCanceledException)
{
// TODO track https://github.com/dotnet/roslyn/issues/37069 regarding these suppressions
#pragma warning disable CS8653
return (WaitIndicatorResult.Canceled, default);
#pragma warning restore CS8653
}
catch (AggregateException aggregate) when (aggregate.InnerExceptions.All(e => e is OperationCanceledException))
{
// TODO track https://github.com/dotnet/roslyn/issues/37069 regarding these suppressions
#pragma warning disable CS8653
return (WaitIndicatorResult.Canceled, default);
#pragma warning restore CS8653
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

using System;

#nullable disable

namespace Microsoft.VisualStudio
{
/// <summary>
Expand Down Expand Up @@ -91,4 +89,4 @@ public static bool IsEarlierThanOrEqualTo(this IComparable source, IComparable c
return source.CompareTo(comparable) <= 0;
}
}
}
}
2 changes: 0 additions & 2 deletions src/Microsoft.VisualStudio.ProjectSystem.Managed/Delimiter.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

#nullable disable

namespace Microsoft.VisualStudio
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
using System;
using System.Collections.Generic;
using System.Collections.Immutable;

#nullable disable
using System.Diagnostics.CodeAnalysis;

namespace Microsoft.VisualStudio
{
Expand Down Expand Up @@ -41,6 +40,7 @@ internal static class ImmutableCollectionLinqExtensions
return false;
}

[return: MaybeNull]
public static T FirstOrDefault<T, TArg>(this ImmutableArray<T> immutableArray, Func<T, TArg, bool> predicate, TArg arg)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the recommended approach for indicating that an output with unconstrained generic type can be null.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ugh - that is not great.

{
foreach (T obj in immutableArray)
Expand All @@ -49,7 +49,7 @@ internal static class ImmutableCollectionLinqExtensions
return obj;
}

return default;
return default!;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately the attribute above doesn't influence the member body, so we need to ! force this here. Tracked by dotnet/roslyn#36039.

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.Contracts;

#nullable disable

namespace Microsoft.VisualStudio
{
internal static class LinqExtensions
{
[Pure]
[return: MaybeNull]
public static T FirstOrDefault<T, TArg>(this IEnumerable<T> source, Func<T, TArg, bool> predicate, TArg arg)
{
foreach (T obj in source)
Expand All @@ -19,10 +19,11 @@ internal static class LinqExtensions
return obj;
}

return default;
return default!;
}

[Pure]
[return: MaybeNull]
public static T SingleOrDefault<T, TArg>(this IEnumerable<T> source, Func<T, TArg, bool> predicate, TArg arg)
{
using (IEnumerator<T> enumerator = source.GetEnumerator())
Expand All @@ -47,7 +48,7 @@ internal static class LinqExtensions
}
}

return default;
return default!;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -416,4 +416,9 @@
<AdditionalFiles Include="PublicAPI.Shipped.txt" />
<AdditionalFiles Include="PublicAPI.Unshipped.txt" />
</ItemGroup>
<ItemGroup>
<None Update="ProjectSystem\Rules\AdditionalDesignTimeBuildInput.xaml">
<Generator>MSBuild:Compile</Generator>
</None>
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

using Microsoft.VisualStudio.Threading;

#nullable disable

namespace Microsoft.VisualStudio.ProjectSystem
{
/// <summary>
Expand Down Expand Up @@ -86,7 +84,7 @@ public async Task LoadCoreAsync()

public Task UnloadAsync()
{
T instance = null;
T? instance = null;
lock (_lock)
{
if (_instanceTaskSource.Task.IsCompleted)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
using System.Collections.Generic;
using System.Collections.Immutable;

#nullable disable

namespace Microsoft.VisualStudio.ProjectSystem
{
/// <summary>
Expand Down Expand Up @@ -42,6 +40,7 @@ public ActiveConfiguredObjects(IReadOnlyList<T> objects, IImmutableSet<string> d
{
Requires.NotNull(dimensionNames, nameof(dimensionNames));
Requires.NotNull(objects, nameof(objects));

if (objects.Count == 0)
throw new ArgumentException(null, nameof(objects));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
using System.Threading.Tasks;
using System.Threading.Tasks.Dataflow;

#nullable disable

namespace Microsoft.VisualStudio.ProjectSystem
{
/// <summary>
Expand All @@ -19,7 +17,7 @@ internal class ActiveConfiguredProjectsLoader : OnceInitializedOnceDisposed
private readonly IActiveConfigurationGroupService _activeConfigurationGroupService;
private readonly IUnconfiguredProjectTasksService _tasksService;
private readonly ITargetBlock<IProjectVersionedValue<IConfigurationGroup<ProjectConfiguration>>> _targetBlock;
private IDisposable _subscription;
private IDisposable? _subscription;

[ImportingConstructor]
public ActiveConfiguredProjectsLoader(UnconfiguredProject project, IActiveConfigurationGroupService activeConfigurationGroupService, IUnconfiguredProjectTasksService tasksService)
Expand Down Expand Up @@ -67,7 +65,6 @@ private async Task OnActiveConfigurationsChanged(IProjectVersionedValue<IConfigu
await _tasksService.LoadedProjectAsync(() =>
{
return _project.LoadConfiguredProjectAsync(configuration);

});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

using Microsoft.VisualStudio.Threading.Tasks;

#nullable disable

namespace Microsoft.VisualStudio.ProjectSystem
{
/// <summary>
Expand All @@ -25,8 +23,8 @@ internal class ConfiguredProjectImplicitActivationTracking : OnceInitializedOnce
private readonly IProjectAsynchronousTasksService _tasksService;
private readonly IActiveConfigurationGroupService _activeConfigurationGroupService;
private readonly ITargetBlock<IProjectVersionedValue<IConfigurationGroup<ProjectConfiguration>>> _targetBlock;
private TaskCompletionSource<object> _isImplicitlyActiveSource = new TaskCompletionSource<object>();
private IDisposable _subscription;
private TaskCompletionSource<object?> _isImplicitlyActiveSource = new TaskCompletionSource<object?>();
private IDisposable? _subscription;

[ImportingConstructor]
public ConfiguredProjectImplicitActivationTracking(ConfiguredProject project, IActiveConfigurationGroupService activeConfigurationGroupService, [Import(ExportContractNames.Scopes.ConfiguredProject)]IProjectAsynchronousTasksService tasksService)
Expand Down Expand Up @@ -133,7 +131,7 @@ private Task OnImplicitlyActivated()

private Task OnImplicitlyDeactivated()
{
var source = new TaskCompletionSource<object>();
var source = new TaskCompletionSource<object?>();

// Make sure the writes in constructor don't
// move to after we publish the value
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

#nullable disable

namespace Microsoft.VisualStudio.ProjectSystem
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
using System.Threading.Tasks;
using System.Threading.Tasks.Dataflow;

#nullable disable

namespace Microsoft.VisualStudio.ProjectSystem
{
/// <summary>
Expand Down Expand Up @@ -40,7 +38,11 @@ internal static class DataflowUtilities
/// </para>
/// <paramref name="target"/> is <see langword="null"/>.
/// </exception>
public static IDisposable LinkToAction(this ISourceBlock<IProjectVersionedValue<IProjectSubscriptionUpdate>> source, Action<IProjectVersionedValue<IProjectSubscriptionUpdate>> target, bool suppressVersionOnlyUpdates = true, params string[] ruleNames)
public static IDisposable LinkToAction(
this ISourceBlock<IProjectVersionedValue<IProjectSubscriptionUpdate>> source,
Action<IProjectVersionedValue<IProjectSubscriptionUpdate>> target,
bool suppressVersionOnlyUpdates = true,
params string[] ruleNames)
{
Requires.NotNull(source, nameof(source));
Requires.NotNull(target, nameof(target));
Expand Down Expand Up @@ -77,7 +79,11 @@ public static IDisposable LinkToAction(this ISourceBlock<IProjectVersionedValue<
/// </para>
/// <paramref name="target"/> is <see langword="null"/>.
/// </exception>
public static IDisposable LinkToAction(this ISourceBlock<IProjectVersionedValue<IProjectSubscriptionUpdate>> source, Action<IProjectVersionedValue<IProjectSubscriptionUpdate>> target, bool suppressVersionOnlyUpdates = true, IEnumerable<string> ruleNames = null)
public static IDisposable LinkToAction(
this ISourceBlock<IProjectVersionedValue<IProjectSubscriptionUpdate>> source,
Action<IProjectVersionedValue<IProjectSubscriptionUpdate>> target,
bool suppressVersionOnlyUpdates = true,
IEnumerable<string>? ruleNames = null)
{
Requires.NotNull(source, nameof(source));
Requires.NotNull(target, nameof(target));
Expand Down Expand Up @@ -114,7 +120,11 @@ public static IDisposable LinkToAction(this ISourceBlock<IProjectVersionedValue<
/// </para>
/// <paramref name="target"/> is <see langword="null"/>.
/// </exception>
public static IDisposable LinkToAsyncAction(this ISourceBlock<IProjectVersionedValue<IProjectSubscriptionUpdate>> source, Func<IProjectVersionedValue<IProjectSubscriptionUpdate>, Task> target, bool suppressVersionOnlyUpdates = true, params string[] ruleNames)
public static IDisposable LinkToAsyncAction(
this ISourceBlock<IProjectVersionedValue<IProjectSubscriptionUpdate>> source,
Func<IProjectVersionedValue<IProjectSubscriptionUpdate>, Task> target,
bool suppressVersionOnlyUpdates = true,
params string[] ruleNames)
{
Requires.NotNull(source, nameof(source));
Requires.NotNull(target, nameof(target));
Expand Down Expand Up @@ -151,7 +161,11 @@ public static IDisposable LinkToAsyncAction(this ISourceBlock<IProjectVersionedV
/// </para>
/// <paramref name="target"/> is <see langword="null"/>.
/// </exception>
public static IDisposable LinkToAsyncAction(this ISourceBlock<IProjectVersionedValue<IProjectSubscriptionUpdate>> source, Func<IProjectVersionedValue<IProjectSubscriptionUpdate>, Task> target, bool suppressVersionOnlyUpdates = true, IEnumerable<string> ruleNames = null)
public static IDisposable LinkToAsyncAction(
this ISourceBlock<IProjectVersionedValue<IProjectSubscriptionUpdate>> source,
Func<IProjectVersionedValue<IProjectSubscriptionUpdate>, Task> target,
bool suppressVersionOnlyUpdates = true,
IEnumerable<string>? ruleNames = null)
{
Requires.NotNull(source, nameof(source));
Requires.NotNull(target, nameof(target));
Expand Down Expand Up @@ -232,7 +246,9 @@ public static IDisposable LinkToAsyncAction<T>(this ISourceBlock<T> source, Func
/// </para>
/// <paramref name="transform"/> is <see langword="null"/>.
/// </exception>
public static DisposableValue<ISourceBlock<TOut>> Transform<TInput, TOut>(this ISourceBlock<IProjectVersionedValue<TInput>> source, Func<IProjectVersionedValue<TInput>, TOut> transform)
public static DisposableValue<ISourceBlock<TOut>> Transform<TInput, TOut>(
this ISourceBlock<IProjectVersionedValue<TInput>> source,
Func<IProjectVersionedValue<TInput>, TOut> transform)
{
Requires.NotNull(source, nameof(source));
Requires.NotNull(transform, nameof(transform));
Expand Down Expand Up @@ -271,7 +287,9 @@ public static IDisposable LinkToAsyncAction<T>(this ISourceBlock<T> source, Func
/// </para>
/// <paramref name="transform"/> is <see langword="null"/>.
/// </exception>
public static DisposableValue<ISourceBlock<TOut>> TransformWithNoDelta<TInput, TOut>(this ISourceBlock<IProjectVersionedValue<TInput>> source, Func<IProjectVersionedValue<TInput>, TOut> transform)
public static DisposableValue<ISourceBlock<TOut>> TransformWithNoDelta<TInput, TOut>(
this ISourceBlock<IProjectVersionedValue<TInput>> source,
Func<IProjectVersionedValue<TInput>, TOut> transform)
{
Requires.NotNull(source, nameof(source));
Requires.NotNull(transform, nameof(transform));
Expand Down Expand Up @@ -314,7 +332,11 @@ public static IDisposable LinkToAsyncAction<T>(this ISourceBlock<T> source, Func
/// </para>
/// <paramref name="transform"/> is <see langword="null"/>.
/// </exception>
public static DisposableValue<ISourceBlock<TOut>> TransformWithNoDelta<TOut>(this ISourceBlock<IProjectVersionedValue<IProjectSubscriptionUpdate>> source, Func<IProjectVersionedValue<IProjectSubscriptionUpdate>, TOut> transform, bool suppressVersionOnlyUpdates, IEnumerable<string> ruleNames = null)
public static DisposableValue<ISourceBlock<TOut>> TransformWithNoDelta<TOut>(
this ISourceBlock<IProjectVersionedValue<IProjectSubscriptionUpdate>> source,
Func<IProjectVersionedValue<IProjectSubscriptionUpdate>, TOut> transform,
bool suppressVersionOnlyUpdates,
IEnumerable<string>? ruleNames = null)
{
Requires.NotNull(source, nameof(source));
Requires.NotNull(transform, nameof(transform));
Expand Down Expand Up @@ -351,7 +373,7 @@ public static DisposableValue<ISourceBlock<TOut>> TransformWithNoDelta<TOut>(thi
{
SynchronizationContext currentSynchronizationContext = SynchronizationContext.Current;
using ExecutionContext copy = context.CreateCopy();
Task result = null;
Task? result = null;
ExecutionContext.Run(
copy,
state =>
Expand All @@ -360,7 +382,7 @@ public static DisposableValue<ISourceBlock<TOut>> TransformWithNoDelta<TOut>(thi
result = function(input);
},
null);
return result;
return result!;
};
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

using Microsoft.VisualStudio.ProjectSystem.Properties;

#nullable disable

namespace Microsoft.VisualStudio.ProjectSystem
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
using System;
using System.Threading.Tasks.Dataflow;

#nullable disable

namespace Microsoft.VisualStudio.ProjectSystem
{
/// <summary>
Expand Down