Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions eng/targets/Imports.targets
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,35 @@
<EditorConfigFiles Condition="'$(IsShipping)' != 'true'" Include="$(RepositoryEngineeringDir)config\globalconfigs\NonShipping.globalconfig" />
</ItemGroup>

<!--
Common content for all Roslyn source packages.
-->

<PropertyGroup Condition="'$(IsSourcePackage)' == 'true'">
<TargetsForTfmSpecificContentInPackage>$(TargetsForTfmSpecificContentInPackage);_AddEditorConfigToSourcePackage;_AddLinkedCompileItemsToSourcePackage</TargetsForTfmSpecificContentInPackage>
<PackageDescription>
$(PackageDescription)

The source code included in this package is subject to arbitrary changes in future versions.
Updating a reference to this package to a newer version of the package may require changes in the referencing project.
No compatibility guarantees are provided.
</PackageDescription>
</PropertyGroup>

<!-- Include SourcePackage.editorconfig in all source packages. -->
<Target Name="_AddEditorConfigToSourcePackage">
<ItemGroup>
<TfmSpecificPackageFile Include="$(MSBuildThisFileDirectory)..\config\SourcePackage.editorconfig" PackagePath="contentFiles/cs/$(TargetFramework)/.editorconfig" />
</ItemGroup>
</Target>

<!-- Include linked files. Arcade SDK only includes files in the project directory. -->
<Target Name="_AddLinkedCompileItemsToSourcePackage">
<ItemGroup>
<TfmSpecificPackageFile Include="@(Compile)" Condition="'%(Compile.Link)' != ''" PackagePath="contentFiles/cs/$(TargetFramework)/%(Compile.Link)" BuildAction="Compile"/>
</ItemGroup>
</Target>

<!-- Check that all shipping assemblies are packaged -->
<Target Name="_CheckTestProjectTargetFileName" BeforeTargets="Build" Condition="'$(IsShippingAssembly)' == 'true' and '$(IsPackable)' != 'true'">
<Error Text="Project output assembly is shipping (IsShipping == $(IsShipping), IsShippingAssembly == '$(IsShippingAssembly)', IsShippingPackage == '$(IsShippingPackage)') but is not packaged (IsPackable == '$(IsPackable)')" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ internal string RelativizeNormalizedPath(string normalizedPath)
if (PathUtilities.IsSameDirectoryOrChildOf(normalizedDirectory, normalizedBaseDirectory))
{
return normalizedPath.Substring(
PathUtilities.IsDirectorySeparator(normalizedBaseDirectory.Last())
PathUtilities.IsDirectorySeparator(normalizedBaseDirectory[^1])
? normalizedBaseDirectory.Length
: normalizedBaseDirectory.Length + 1);
}
Expand Down
6 changes: 3 additions & 3 deletions src/Compilers/CSharp/Portable/Syntax/SyntaxNormalizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -927,8 +927,8 @@ private static bool NeedsSeparator(SyntaxToken token, SyntaxToken next)
}
else if (token.Width > 1 && next.Width > 1)
{
var tokenLastChar = token.Text.Last();
var nextFirstChar = next.Text.First();
var tokenLastChar = token.Text[^1];
var nextFirstChar = next.Text[0];
if (tokenLastChar == nextFirstChar && TokenCharacterCanBeDoubled(tokenLastChar))
{
return true;
Expand Down Expand Up @@ -1251,7 +1251,7 @@ private static bool EndsInLineBreak(SyntaxTrivia trivia)
if (trivia.Kind() == SyntaxKind.PreprocessingMessageTrivia || trivia.Kind() == SyntaxKind.DisabledTextTrivia)
{
var text = trivia.ToFullString();
return text.Length > 0 && SyntaxFacts.IsNewLine(text.Last());
return text.Length > 0 && SyntaxFacts.IsNewLine(text[^1]);
}

if (trivia.HasStructure)
Expand Down
2 changes: 2 additions & 0 deletions src/Compilers/Core/Portable/InternalUtilities/Hash.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

#nullable enable

using System;
using System.Collections.Generic;
using System.Collections.Immutable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

#nullable enable

using System.Diagnostics.CodeAnalysis;

namespace Roslyn.Utilities
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

#nullable enable

using System;
using System.Collections.Generic;
using System.Collections.Immutable;
Expand All @@ -13,6 +15,8 @@ namespace Roslyn.Utilities
{
internal static class StringExtensions
{
private static readonly Func<char, char> s_toLower = char.ToLower;
private static readonly Func<char, char> s_toUpper = char.ToUpper;
private static ImmutableArray<string> s_lazyNumerals;
private static UTF8Encoding? s_lazyUtf8;

Expand All @@ -30,19 +34,7 @@ internal static string GetNumeral(int number)
}

public static string Join(this IEnumerable<string?> source, string separator)
{
if (source == null)
{
throw new ArgumentNullException(nameof(source));
}

if (separator == null)
{
throw new ArgumentNullException(nameof(separator));
}

return string.Join(separator, source);
}
=> string.Join(separator, source);

public static bool LooksLikeInterfaceName(this string name)
{
Expand All @@ -54,9 +46,6 @@ public static bool LooksLikeTypeParameterName(this string name)
return name.Length >= 3 && name[0] == 'T' && char.IsUpper(name[1]) && char.IsLower(name[2]);
}

private static readonly Func<char, char> s_toLower = char.ToLower;
private static readonly Func<char, char> s_toUpper = char.ToUpper;

[return: NotNullIfNotNull(parameterName: nameof(shortName))]
public static string? ToPascalCase(
this string? shortName,
Expand Down Expand Up @@ -228,32 +217,6 @@ internal static string Unquote(this string arg, out bool quoted)
}
}

// String isn't IEnumerable<char> in the current Portable profile.
internal static char First(this string arg)
{
return arg[0];
}

// String isn't IEnumerable<char> in the current Portable profile.
internal static char Last(this string arg)
{
return arg[arg.Length - 1];
}

// String isn't IEnumerable<char> in the current Portable profile.
internal static bool All(this string arg, Predicate<char> predicate)
{
foreach (char c in arg)
{
if (!predicate(c))
{
return false;
}
}

return true;
}

public static int GetCaseInsensitivePrefixLength(this string string1, string string2)
{
int x = 0;
Expand Down
3 changes: 2 additions & 1 deletion src/Compilers/Core/Portable/SpecialTypeExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

#nullable enable

using System;
using System.Diagnostics;
using Roslyn.Utilities;

namespace Microsoft.CodeAnalysis
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

#nullable enable

#if !MICROSOFT_CODEANALYSIS_CONTRACTS_NO_ERROR_REPORTING

using System;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;
using Microsoft.CodeAnalysis.ErrorReporting;
using Roslyn.Utilities;

namespace Microsoft.CodeAnalysis
namespace Microsoft.CodeAnalysis.ErrorReporting
{
internal static class FailFast
{
Expand Down Expand Up @@ -109,3 +111,4 @@ internal static void Assert([DoesNotReturnIf(false)] bool condition, string? mes
}
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

#nullable enable

#if !MICROSOFT_CODEANALYSIS_CONTRACTS_NO_ERROR_REPORTING

using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Tasks;

namespace Microsoft.CodeAnalysis.ErrorReporting
{
Expand Down Expand Up @@ -221,6 +226,25 @@ public static bool ReportAndCatchUnlessCanceled(Exception exception, Cancellatio
return ReportAndCatch(exception, severity);
}

public static Task ReportNonFatalErrorAsync(this Task task)
{
_ = task.ContinueWith(p => ReportAndCatchUnlessCanceled(p.Exception!),
CancellationToken.None,
TaskContinuationOptions.OnlyOnFaulted | TaskContinuationOptions.ExecuteSynchronously,
TaskScheduler.Default);

return task;
}

public static Task ReportNonFatalErrorUnlessCancelledAsync(this Task task, CancellationToken cancellationToken)
{
_ = task.ContinueWith(p => ReportAndCatchUnlessCanceled(p.Exception!, cancellationToken),
CancellationToken.None,
TaskContinuationOptions.OnlyOnFaulted | TaskContinuationOptions.ExecuteSynchronously,
TaskScheduler.Default);

return task;
}
#endif

// We use a Guid for the marker because it is used as a key in an exceptions Data dictionary, so we must make sure
Expand Down Expand Up @@ -312,3 +336,5 @@ internal enum ErrorSeverity
Critical
}
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
<Compile Include="$(MSBuildThisFileDirectory)ExceptionUtilities.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Index.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Range.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ErrorReporting\FatalError.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ErrorReporting\FailFast.cs" />
</ItemGroup>
<ItemGroup Condition="'$(DefaultLanguageSourceExtension)' != '' AND '$(BuildingInsideVisualStudio)' != 'true'">
<ExpectedCompile Include="$(MSBuildThisFileDirectory)**\*$(DefaultLanguageSourceExtension)" />
Expand Down
17 changes: 0 additions & 17 deletions src/Dependencies/Directory.Build.targets

This file was deleted.

2 changes: 0 additions & 2 deletions src/Dependencies/SourcePackage.editorconfig

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@
<!-- Remove once https://github.com/NuGet/Home/issues/8583 is fixed -->
<NoWarn>$(NoWarn);NU5128</NoWarn>
</PropertyGroup>
<ItemGroup>
<!-- ⚠ Consuming projects will be required to manually reproduce the APIs for any linked files added here -->
<Compile Include="..\..\Compilers\Core\Portable\InternalUtilities\FatalError.cs" Link="External\FatalError.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="System.Collections.Immutable" />
<PackageReference Include="System.Threading.Tasks.Extensions" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using Microsoft.CodeAnalysis.Editing;
using Microsoft.CodeAnalysis.Editor.BackgroundWorkIndicator;
using Microsoft.CodeAnalysis.Editor.Shared.Extensions;
using Microsoft.CodeAnalysis.ErrorReporting;
using Microsoft.CodeAnalysis.EventHookup;
using Microsoft.CodeAnalysis.Formatting;
using Microsoft.CodeAnalysis.LanguageService;
Expand All @@ -26,7 +27,6 @@
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Text.Editor.Commanding.Commands;
using Microsoft.VisualStudio.Threading;
using Roslyn.Utilities;

namespace Microsoft.CodeAnalysis.Editor.CSharp.EventHookup;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using Microsoft.CodeAnalysis.Editor.BackgroundWorkIndicator;
using Microsoft.CodeAnalysis.Editor.Shared.Extensions;
using Microsoft.CodeAnalysis.Editor.Shared.Utilities;
using Microsoft.CodeAnalysis.ErrorReporting;
using Microsoft.CodeAnalysis.Internal.Log;
using Microsoft.CodeAnalysis.Options;
using Microsoft.CodeAnalysis.Progress;
Expand All @@ -20,7 +21,6 @@
using Microsoft.VisualStudio.Text.Editor;
using Microsoft.VisualStudio.Text.Editor.Commanding.Commands;
using Microsoft.VisualStudio.Threading;
using Roslyn.Utilities;

namespace Microsoft.CodeAnalysis.AddImport;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
using Microsoft.CodeAnalysis.Editor.BackgroundWorkIndicator;
using Microsoft.CodeAnalysis.Editor.Shared.Extensions;
using Microsoft.CodeAnalysis.Editor.Shared.Utilities;
using Microsoft.CodeAnalysis.ErrorReporting;
using Microsoft.CodeAnalysis.Navigation;
using Microsoft.CodeAnalysis.Notification;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.Shared.TestHooks;
using Microsoft.CodeAnalysis.Text;
using Microsoft.VisualStudio.Commanding;
using Microsoft.VisualStudio.Language.Intellisense.Utilities;
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Text.Editor.Commanding.Commands;
using Microsoft.VisualStudio.Threading;
Expand Down
1 change: 1 addition & 0 deletions src/EditorFeatures/Core/IntelliSense/ModelComputation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Editor.Shared.Extensions;
using Microsoft.CodeAnalysis.Editor.Shared.Utilities;
using Microsoft.CodeAnalysis.ErrorReporting;
using Microsoft.CodeAnalysis.Shared.TestHooks;
using Microsoft.VisualStudio.Threading;
using Roslyn.Utilities;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Editor.BackgroundWorkIndicator;
using Microsoft.CodeAnalysis.ErrorReporting;
using Microsoft.CodeAnalysis.Navigation;
using Microsoft.CodeAnalysis.Shared.TestHooks;
using Microsoft.VisualStudio.Language.Intellisense;
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Text.Editor;
using Roslyn.Utilities;

namespace Microsoft.CodeAnalysis.Editor.NavigableSymbols;

Expand Down
2 changes: 1 addition & 1 deletion src/EditorFeatures/Core/NavigateTo/NavigateToHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Editor.Shared.Utilities;
using Microsoft.CodeAnalysis.ErrorReporting;
using Microsoft.CodeAnalysis.NavigateTo;
using Microsoft.CodeAnalysis.Navigation;
using Microsoft.CodeAnalysis.Shared.TestHooks;
using Microsoft.VisualStudio.Utilities;
using Roslyn.Utilities;

namespace Microsoft.CodeAnalysis.Editor.NavigateTo;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
using System.Collections.Immutable;
using System.Threading;
using Microsoft.CodeAnalysis.Editor.Shared.Utilities;
using Microsoft.CodeAnalysis.ErrorReporting;
using Microsoft.CodeAnalysis.NavigateTo;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.Shared.TestHooks;
using Microsoft.VisualStudio.Language.NavigateTo.Interfaces;
using Microsoft.VisualStudio.Utilities;
using Roslyn.Utilities;

namespace Microsoft.CodeAnalysis.Editor.Implementation.NavigateTo;

Expand Down
Loading