Skip to content

Commit

Permalink
Merge branch 'master' into update-build-tools
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeRobich committed May 6, 2021
2 parents ea76114 + 469b8aa commit 6951777
Show file tree
Hide file tree
Showing 26 changed files with 260 additions and 100 deletions.
Binary file added build/OmniSharpKey.snk
Binary file not shown.
9 changes: 5 additions & 4 deletions build/Packages.props
Expand Up @@ -11,11 +11,12 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Update="Cake.Scripting.Transport" Version="0.3.0" />
<PackageReference Update="Cake.Scripting.Transport" Version="0.6.4" />

<PackageReference Update="Dotnet.Script.DependencyModel" Version="1.1.0" />
<PackageReference Update="Dotnet.Script.DependencyModel.NuGet" Version="1.1.0" />
<PackageReference Update="ICSharpCode.Decompiler" Version="7.0.0.6488" />

<PackageReference Update="Dotnet.Script.DependencyModel" Version="1.0.2" />
<PackageReference Update="Dotnet.Script.DependencyModel.NuGet" Version="1.0.1" />
<PackageReference Update="ICSharpCode.Decompiler" Version="7.0.0.6372-preview3" />
<PackageReference Update="McMaster.Extensions.CommandLineUtils" Version="2.2.4" />

<PackageReference Update="Microsoft.AspNetCore.Diagnostics" Version="$(AspNetCorePackageVersion)" />
Expand Down
3 changes: 3 additions & 0 deletions build/Settings.props
Expand Up @@ -27,6 +27,9 @@
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
<AllowedReferenceRelatedFileExtensions>$(AllowedReferenceRelatedFileExtensions);.pdb</AllowedReferenceRelatedFileExtensions>
<SignAssembly>true</SignAssembly>
<DelaySign>false</DelaySign>
<AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)\OmniSharpKey.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>

<ItemGroup>
Expand Down
30 changes: 22 additions & 8 deletions src/OmniSharp.Abstractions/AssemblyInfo.cs
@@ -1,10 +1,24 @@
using System.Runtime.CompilerServices;
using OmniSharp;

[assembly: InternalsVisibleTo("OmniSharp")]
[assembly: InternalsVisibleTo("OmniSharp.Host")]
[assembly: InternalsVisibleTo("OmniSharp.MSBuild")]
[assembly: InternalsVisibleTo("OmniSharp.Roslyn")]
[assembly: InternalsVisibleTo("OmniSharp.Roslyn.CSharp")]
[assembly: InternalsVisibleTo("OmniSharp.DotNetTest.Tests")]
[assembly: InternalsVisibleTo("OmniSharp.Tests")]
[assembly: InternalsVisibleTo("OmniSharp.LanguageServerProtocol")]
[assembly: InternalsVisibleTo("OmniSharp" + OmniSharpPublicKey.Key)]
[assembly: InternalsVisibleTo("OmniSharp.Host" + OmniSharpPublicKey.Key)]
[assembly: InternalsVisibleTo("OmniSharp.MSBuild" + OmniSharpPublicKey.Key)]
[assembly: InternalsVisibleTo("OmniSharp.Roslyn" + OmniSharpPublicKey.Key)]
[assembly: InternalsVisibleTo("OmniSharp.Roslyn.CSharp" + OmniSharpPublicKey.Key)]
[assembly: InternalsVisibleTo("OmniSharp.DotNetTest.Tests" + OmniSharpPublicKey.Key)]
[assembly: InternalsVisibleTo("OmniSharp.Tests" + OmniSharpPublicKey.Key)]
[assembly: InternalsVisibleTo("OmniSharp.LanguageServerProtocol" + OmniSharpPublicKey.Key)]


namespace OmniSharp
{
public class OmniSharpPublicKey
{
public const string Key = ", PublicKey=" + "0024000004800000940000000602000000240000525341310004000001000100917302efc152e6" +
"464679d4625bd9989e12d4662a9eaadf284d04992881c0e7b16e756e63ef200a02c4054d4d31e2" +
"1b9aa0b0b873bcefca8cd42ec583a3db509665c9b22318ceceec581663fc07e2422bb2135539ba" +
"8a517c209ac175fff07c5af10cef636e04cae91d28f51fcde5d14c1a9bfed06e096cf977fd0d60" +
"002a3ea6";
}
}
5 changes: 3 additions & 2 deletions src/OmniSharp.Cake/AssemblyInfo.cs
@@ -1,3 +1,4 @@
using System.Runtime.CompilerServices;
using OmniSharp;
using System.Runtime.CompilerServices;

[assembly: InternalsVisibleTo("OmniSharp.Cake.Tests")]
[assembly: InternalsVisibleTo("OmniSharp.Cake.Tests" + OmniSharpPublicKey.Key)]
2 changes: 1 addition & 1 deletion src/OmniSharp.Cake/OmniSharp.Cake.csproj
Expand Up @@ -18,4 +18,4 @@
<PackageReference Include="Cake.Scripting.Transport" />
</ItemGroup>

</Project>
</Project>
5 changes: 3 additions & 2 deletions src/OmniSharp.DotNetTest/AssemblyInfo.cs
@@ -1,3 +1,4 @@
using System.Runtime.CompilerServices;
using OmniSharp;
using System.Runtime.CompilerServices;

[assembly: InternalsVisibleTo("OmniSharp.DotNetTest.Tests")]
[assembly: InternalsVisibleTo("OmniSharp.DotNetTest.Tests" + OmniSharpPublicKey.Key)]
13 changes: 7 additions & 6 deletions src/OmniSharp.Host/AssemblyInfo.cs
@@ -1,7 +1,8 @@
using System.Runtime.CompilerServices;
using OmniSharp;
using System.Runtime.CompilerServices;

[assembly: InternalsVisibleTo("OmniSharp.Http.Tests")]
[assembly: InternalsVisibleTo("OmniSharp.MSBuild.Tests")]
[assembly: InternalsVisibleTo("OmniSharp.Roslyn.CSharp.Tests")]
[assembly: InternalsVisibleTo("OmniSharp.Stdio.Tests")]
[assembly: InternalsVisibleTo("TestUtility")]
[assembly: InternalsVisibleTo("OmniSharp.Http.Tests" + OmniSharpPublicKey.Key)]
[assembly: InternalsVisibleTo("OmniSharp.MSBuild.Tests" + OmniSharpPublicKey.Key)]
[assembly: InternalsVisibleTo("OmniSharp.Roslyn.CSharp.Tests" + OmniSharpPublicKey.Key)]
[assembly: InternalsVisibleTo("OmniSharp.Stdio.Tests" + OmniSharpPublicKey.Key)]
[assembly: InternalsVisibleTo("TestUtility" + OmniSharpPublicKey.Key)]
64 changes: 32 additions & 32 deletions src/OmniSharp.Host/ConfigurationBuilder.cs
@@ -1,55 +1,55 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.FileProviders;
using OmniSharp.Internal;
using OmniSharp.Utilities;

namespace OmniSharp
{
public class ConfigurationBuilder : IConfigurationBuilder
public class ConfigurationBuilder
{
private readonly IOmniSharpEnvironment _environment;
private readonly IConfigurationBuilder _builder;

public ConfigurationBuilder(IOmniSharpEnvironment environment)
{
_environment = environment;
_builder = new Microsoft.Extensions.Configuration.ConfigurationBuilder()
.SetBasePath(AppContext.BaseDirectory);
}

public IConfigurationBuilder Add(IConfigurationSource source)
public ConfigurationResult Build(Action<IConfigurationBuilder> additionalSetup = null)
{
_builder.Add(source);
return this;
}

public IConfigurationRoot Build()
{
var configBuilder = new Microsoft.Extensions.Configuration.ConfigurationBuilder()
.SetBasePath(AppContext.BaseDirectory)
.AddEnvironmentVariables("OMNISHARP_");

if (_environment.AdditionalArguments?.Length > 0)
try
{
configBuilder.AddCommandLine(_environment.AdditionalArguments);
var configBuilder = new Microsoft.Extensions.Configuration.ConfigurationBuilder()
.SetBasePath(AppContext.BaseDirectory)
.AddEnvironmentVariables("OMNISHARP_");

if (_environment.AdditionalArguments?.Length > 0)
{
configBuilder.AddCommandLine(_environment.AdditionalArguments);
}

// Use the global omnisharp config if there's any in the shared path
configBuilder.CreateAndAddGlobalOptionsFile(_environment);

// Use the local omnisharp config if there's any in the root path
configBuilder.AddJsonFile(
new PhysicalFileProvider(_environment.TargetDirectory).WrapForPolling(),
Constants.OptionsFile,
optional: true,
reloadOnChange: true);

// bootstrap additional host configuration at the end
additionalSetup?.Invoke(configBuilder);

var config = configBuilder.Build();
return new ConfigurationResult(config);
}
catch (Exception ex)
{
return new ConfigurationResult(ex);
}

// Use the global omnisharp config if there's any in the shared path
configBuilder.CreateAndAddGlobalOptionsFile(_environment);

// Use the local omnisharp config if there's any in the root path
configBuilder.AddJsonFile(
new PhysicalFileProvider(_environment.TargetDirectory).WrapForPolling(),
Constants.OptionsFile,
optional: true,
reloadOnChange: true);

return configBuilder.Build();
}

public IDictionary<string, object> Properties => _builder.Properties;
public IList<IConfigurationSource> Sources => _builder.Sources;
}
}
25 changes: 25 additions & 0 deletions src/OmniSharp.Host/ConfigurationResult.cs
@@ -0,0 +1,25 @@
using System;
using Microsoft.Extensions.Configuration;

namespace OmniSharp
{
public class ConfigurationResult
{
public ConfigurationResult(IConfigurationRoot configuration)
{
Configuration = configuration;
}

public ConfigurationResult(Exception exception)
{
Exception = exception;
Configuration = new ConfigurationRoot(Array.Empty<IConfigurationProvider>());
}

public IConfigurationRoot Configuration { get; }

public Exception Exception { get; }

public bool HasError() => Exception != null;
}
}
9 changes: 5 additions & 4 deletions src/OmniSharp.Http/AssemblyInfo.cs
@@ -1,5 +1,6 @@
using System.Runtime.CompilerServices;
using OmniSharp;
using System.Runtime.CompilerServices;

[assembly: InternalsVisibleTo("OmniSharp")]
[assembly: InternalsVisibleTo("TestUtility")]
[assembly: InternalsVisibleTo("OmniSharp.Http.Tests")]
[assembly: InternalsVisibleTo("OmniSharp" + OmniSharpPublicKey.Key)]
[assembly: InternalsVisibleTo("TestUtility" + OmniSharpPublicKey.Key)]
[assembly: InternalsVisibleTo("OmniSharp.Http.Tests" + OmniSharpPublicKey.Key)]
10 changes: 8 additions & 2 deletions src/OmniSharp.Http/Startup.cs
Expand Up @@ -32,8 +32,8 @@ public Startup(IOmniSharpEnvironment environment, IEventEmitter eventEmitter, Pl

public IServiceProvider ConfigureServices(IServiceCollection services)
{
var configuration = new ConfigurationBuilder(_environment).Build();
var serviceProvider = CompositionHostBuilder.CreateDefaultServiceProvider(_environment, configuration, _eventEmitter, services,
var configurationResult = new ConfigurationBuilder(_environment).Build();
var serviceProvider = CompositionHostBuilder.CreateDefaultServiceProvider(_environment, configurationResult.Configuration, _eventEmitter, services,
configureLogging: builder =>
{
builder.AddConsole();
Expand All @@ -56,6 +56,12 @@ public IServiceProvider ConfigureServices(IServiceCollection services)

var loggerFactory = serviceProvider.GetRequiredService<ILoggerFactory>();
var logger = loggerFactory.CreateLogger<Startup>();

if (configurationResult.HasError())
{
logger.LogError(configurationResult.Exception, "There was an error when reading the OmniSharp configuration, starting with the default options.");
}

var assemblyLoader = serviceProvider.GetRequiredService<IAssemblyLoader>();
_compositionHost = new CompositionHostBuilder(serviceProvider)
.WithOmniSharpAssemblies()
Expand Down
11 changes: 6 additions & 5 deletions src/OmniSharp.LanguageServerProtocol/AssemblyInfo.cs
@@ -1,6 +1,7 @@
using System.Runtime.CompilerServices;
using OmniSharp;
using System.Runtime.CompilerServices;

[assembly: InternalsVisibleTo("TestUtility")]
[assembly: InternalsVisibleTo("OmniSharp")]
[assembly: InternalsVisibleTo("OmniSharp.Stdio.Tests")]
[assembly: InternalsVisibleTo("OmniSharp.Lsp.Tests")]
[assembly: InternalsVisibleTo("TestUtility" + OmniSharpPublicKey.Key)]
[assembly: InternalsVisibleTo("OmniSharp" + OmniSharpPublicKey.Key)]
[assembly: InternalsVisibleTo("OmniSharp.Stdio.Tests" + OmniSharpPublicKey.Key)]
[assembly: InternalsVisibleTo("OmniSharp.Lsp.Tests" + OmniSharpPublicKey.Key)]
15 changes: 7 additions & 8 deletions src/OmniSharp.LanguageServerProtocol/LanguageServerHost.cs
Expand Up @@ -202,24 +202,23 @@ private static LogLevel GetLogLevel(InitializeTrace initializeTrace)
application.LogLevel < logLevel ? application.LogLevel : logLevel,
application.OtherArgs.ToArray());

var configurationRoot = new Microsoft.Extensions.Configuration.ConfigurationBuilder()
.AddConfiguration(new ConfigurationBuilder(environment).Build())
.AddConfiguration(server.Configuration.GetSection("csharp"))
.AddConfiguration(server.Configuration.GetSection("omnisharp"))
.Build()
;

var configurationResult = new ConfigurationBuilder(environment).Build(b =>
b.AddConfiguration(server.Configuration.GetSection("csharp")).AddConfiguration(server.Configuration.GetSection("omnisharp")));
var eventEmitter = new LanguageServerEventEmitter(server);

services.AddSingleton(server)
.AddSingleton<ILanguageServerFacade>(server);

var serviceProvider =
CompositionHostBuilder.CreateDefaultServiceProvider(environment, configurationRoot, eventEmitter,
CompositionHostBuilder.CreateDefaultServiceProvider(environment, configurationResult.Configuration, eventEmitter,
services, GetLogBuilderAction(configureLogging, environment.LogLevel));

var loggerFactory = serviceProvider.GetService<ILoggerFactory>();
var logger = loggerFactory.CreateLogger<LanguageServerHost>();
if (configurationResult.HasError())
{
logger.LogError(configurationResult.Exception, "There was an error when reading the OmniSharp configuration, starting with the default options.");
}

var options = serviceProvider.GetRequiredService<IOptionsMonitor<OmniSharpOptions>>();
var plugins = application.CreatePluginAssemblies(options.CurrentValue, environment);
Expand Down
7 changes: 4 additions & 3 deletions src/OmniSharp.MSBuild/AssemblyInfo.cs
@@ -1,4 +1,5 @@
using System.Runtime.CompilerServices;
using OmniSharp;
using System.Runtime.CompilerServices;

[assembly: InternalsVisibleTo("OmniSharp.MSBuild.Tests")]
[assembly: InternalsVisibleTo("TestUtility")]
[assembly: InternalsVisibleTo("OmniSharp.MSBuild.Tests" + OmniSharpPublicKey.Key)]
[assembly: InternalsVisibleTo("TestUtility" + OmniSharpPublicKey.Key)]
Expand Up @@ -56,7 +56,7 @@ public async Task<BlockStructureResponse> Handle(BlockStructureRequest request)
var document = await _workspace.GetDocumentFromFullProjectModelAsync(request.FileName);
if (document == null)
{
return null;
return new BlockStructureResponse { Spans = Array.Empty<CodeFoldingBlock>() };
}

var text = await document.GetTextAsync();
Expand Down
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Composition;
using System.Threading.Tasks;
Expand Down Expand Up @@ -36,7 +37,7 @@ public async Task<CodeStructureResponse> Handle(CodeStructureRequest request)
var document = await _workspace.GetDocumentFromFullProjectModelAsync(request.FileName);
if (document == null)
{
return null;
return new CodeStructureResponse { Elements = Array.Empty<CodeElement>() };
}

var elements = await GetCodeElementsAsync(document);
Expand Down
5 changes: 3 additions & 2 deletions src/OmniSharp.Roslyn/AssemblyInfo.cs
@@ -1,4 +1,5 @@
using System.Runtime.CompilerServices;
using OmniSharp;

[assembly: InternalsVisibleTo("OmniSharp.Tests")]
[assembly: InternalsVisibleTo("OmniSharp.Roslyn.CSharp")]
[assembly: InternalsVisibleTo("OmniSharp.Tests" + OmniSharpPublicKey.Key)]
[assembly: InternalsVisibleTo("OmniSharp.Roslyn.CSharp" + OmniSharpPublicKey.Key)]
5 changes: 3 additions & 2 deletions src/OmniSharp.Roslyn/Properties/AssemblyInfo.cs
@@ -1,4 +1,5 @@
using System.Runtime.CompilerServices;
using OmniSharp;
using System.Runtime.CompilerServices;

[assembly: InternalsVisibleTo("OmniSharp.Roslyn.CSharp.Tests")]
[assembly: InternalsVisibleTo("OmniSharp.Roslyn.CSharp.Tests" + OmniSharpPublicKey.Key)]

17 changes: 9 additions & 8 deletions src/OmniSharp.Shared/AssemblyInfo.cs
@@ -1,9 +1,10 @@
using System.Runtime.CompilerServices;
using OmniSharp;
using System.Runtime.CompilerServices;

[assembly: InternalsVisibleTo("OmniSharp")]
[assembly: InternalsVisibleTo("OmniSharp.Host")]
[assembly: InternalsVisibleTo("OmniSharp.MSBuild")]
[assembly: InternalsVisibleTo("OmniSharp.Roslyn")]
[assembly: InternalsVisibleTo("OmniSharp.Roslyn.CSharp")]
[assembly: InternalsVisibleTo("OmniSharp.DotNetTest.Tests")]
[assembly: InternalsVisibleTo("OmniSharp.Tests")]
[assembly: InternalsVisibleTo("OmniSharp" + OmniSharpPublicKey.Key)]
[assembly: InternalsVisibleTo("OmniSharp.Host" + OmniSharpPublicKey.Key)]
[assembly: InternalsVisibleTo("OmniSharp.MSBuild" + OmniSharpPublicKey.Key)]
[assembly: InternalsVisibleTo("OmniSharp.Roslyn" + OmniSharpPublicKey.Key)]
[assembly: InternalsVisibleTo("OmniSharp.Roslyn.CSharp" + OmniSharpPublicKey.Key)]
[assembly: InternalsVisibleTo("OmniSharp.DotNetTest.Tests" + OmniSharpPublicKey.Key)]
[assembly: InternalsVisibleTo("OmniSharp.Tests" + OmniSharpPublicKey.Key)]
8 changes: 6 additions & 2 deletions src/OmniSharp.Stdio.Driver/Program.cs
Expand Up @@ -51,9 +51,9 @@ internal class Program
var environment = application.CreateEnvironment();
Configuration.ZeroBasedIndices = application.ZeroBasedIndices;
var configuration = new ConfigurationBuilder(environment).Build();
var configurationResult = new ConfigurationBuilder(environment).Build();
var writer = new SharedTextWriter(output);
var serviceProvider = CompositionHostBuilder.CreateDefaultServiceProvider(environment, configuration, new StdioEventEmitter(writer),
var serviceProvider = CompositionHostBuilder.CreateDefaultServiceProvider(environment, configurationResult.Configuration, new StdioEventEmitter(writer),
configureLogging: builder => builder.AddStdio(writer));
var loggerFactory = serviceProvider.GetRequiredService<ILoggerFactory>();
Expand All @@ -63,6 +63,10 @@ internal class Program
var plugins = application.CreatePluginAssemblies(options.CurrentValue, environment);
var logger = loggerFactory.CreateLogger<Program>();
if (configurationResult.HasError())
{
logger.LogError(configurationResult.Exception, "There was an error when reading the OmniSharp configuration, starting with the default options.");
}
var compositionHostBuilder = new CompositionHostBuilder(serviceProvider)
.WithOmniSharpAssemblies()
.WithAssemblies(assemblyLoader.LoadByAssemblyNameOrPath(logger, plugins.AssemblyNames).ToArray());
Expand Down
9 changes: 5 additions & 4 deletions src/OmniSharp.Stdio/AssemblyInfo.cs
@@ -1,5 +1,6 @@
using System.Runtime.CompilerServices;
using OmniSharp;
using System.Runtime.CompilerServices;

[assembly: InternalsVisibleTo("OmniSharp")]
[assembly: InternalsVisibleTo("TestUtility")]
[assembly: InternalsVisibleTo("OmniSharp.Stdio.Tests")]
[assembly: InternalsVisibleTo("OmniSharp" + OmniSharpPublicKey.Key)]
[assembly: InternalsVisibleTo("TestUtility" + OmniSharpPublicKey.Key)]
[assembly: InternalsVisibleTo("OmniSharp.Stdio.Tests" + OmniSharpPublicKey.Key)]

0 comments on commit 6951777

Please sign in to comment.