Skip to content

Re-organize the project layout to build a single executable #13

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

Merged
merged 1 commit into from
Aug 29, 2018
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

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,26 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Azure.Functions.PowerShell.Worker.Messaging\Azure.Functions.PowerShell.Worker.Messaging.csproj" />
</ItemGroup>
<Product>Azure Function PowerShell Language Worker</Product>
<Company>Microsoft Corporation</Company>
<Copyright>(c) Microsoft Corporation. All rights reserved.</Copyright>

<LangVersion>Latest</LangVersion>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<SuppressNETCoreSdkPreviewMessage>true</SuppressNETCoreSdkPreviewMessage>
<NeutralLanguage>en-US</NeutralLanguage>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.1.1" />
<PackageReference Include="Microsoft.PowerShell.SDK" Version="6.1.0-rc.1" />
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
<PackageReference Include="CommandLineParser" Version="2.3.0" />
<PackageReference Include="Grpc" Version="1.14.1" />
<PackageReference Include="Google.Protobuf" Version="3.6.1" />
</ItemGroup>

<ItemGroup>
Expand All @@ -22,8 +31,4 @@
</None>
</ItemGroup>

<PropertyGroup>
<LangVersion>latest</LangVersion>
</PropertyGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace Microsoft.Azure.Functions.PowerShellWorker
{
public class FunctionInfo
internal class FunctionInfo
{
public string Directory {get; set;}
public string HttpOutputName {get; set;}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace Microsoft.Azure.Functions.PowerShellWorker
{
public class FunctionLoader
internal class FunctionLoader
{
readonly MapField<string, Function> _LoadedFunctions = new MapField<string, Function>();

Expand All @@ -30,7 +30,7 @@ public void Load(string functionId, RpcFunctionMetadata metadata)
}
}

public class Function
internal class Function
{
public string EntryPoint {get; internal set;}
public FunctionInfo Info {get; internal set;}
Expand Down
47 changes: 40 additions & 7 deletions src/Azure.Functions.PowerShell.Worker/Http/HttpRequestContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,49 @@

namespace Microsoft.Azure.Functions.PowerShellWorker
{
/// <summary>
/// Custom type represent the context of the in-coming Http request.
/// </summary>
public class HttpRequestContext : IEquatable<HttpRequestContext>
{
public object Body {get; set;}
public MapField<string, string> Headers {get; set;}
public string Method {get; set;}
public string Url {get; set;}
public MapField<string, string> Params {get; set;}
public MapField<string, string> Query {get; set;}
public object RawBody {get; set;}
/// <summary>
/// Gets the Body of the Http request.
/// </summary>
public object Body { get; internal set; }

/// <summary>
/// Gets the Headers of the Http request.
/// </summary>
public MapField<string, string> Headers { get; internal set; }

/// <summary>
/// Gets the Method of the Http request.
/// </summary>
public string Method { get; internal set; }

/// <summary>
/// Gets the Url of the Http request.
/// </summary>
public string Url { get; internal set; }

/// <summary>
/// Gets the Params of the Http request.
/// </summary>
public MapField<string, string> Params { get; internal set; }

/// <summary>
/// Gets the Query of the Http request.
/// </summary>
public MapField<string, string> Query { get; internal set; }

/// <summary>
/// Gets the RawBody of the Http request.
/// </summary>
public object RawBody { get; internal set; }

/// <summary>
/// Compare with another HttpRequestContext object.
/// </summary>
public bool Equals(HttpRequestContext other)
{
return Method == other.Method
Expand Down
35 changes: 30 additions & 5 deletions src/Azure.Functions.PowerShell.Worker/Http/HttpResponseContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,39 @@

namespace Microsoft.Azure.Functions.PowerShellWorker
{
/// <summary>
/// Custom type represent the context of the Http response.
/// </summary>
public class HttpResponseContext : IEquatable<HttpResponseContext>
{
public object Body {get; set;}
public string ContentType {get; set;} = "text/plain";
public bool EnableContentNegotiation {get; set;} = false;
public Hashtable Headers {get; set;} = new Hashtable();
public string StatusCode {get; set;} = "200";
/// <summary>
/// Gets or sets the Body of the Http response.
/// </summary>
public object Body { get; set; }

/// <summary>
/// Gets or sets the ContentType of the Http response.
/// </summary>
public string ContentType { get; set; } = "text/plain";

/// <summary>
/// Gets or sets the EnableContentNegotiation of the Http response.
/// </summary>
public bool EnableContentNegotiation { get; set; } = false;

/// <summary>
/// Gets or sets the Headers of the Http response.
/// </summary>
public Hashtable Headers { get; set; } = new Hashtable();

/// <summary>
/// Gets or sets the StatusCode of the Http response.
/// </summary>
public string StatusCode { get; set; } = "200";

/// <summary>
/// Compare with another HttpResponseContext object.
/// </summary>
public bool Equals(HttpResponseContext other)
{
bool sameHeaders = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

namespace Microsoft.Azure.Functions.PowerShellWorker.Messaging
{
public class FunctionMessagingClient : IDisposable
internal class FunctionMessagingClient : IDisposable
{
SemaphoreSlim _writeStreamHandle = new SemaphoreSlim(1, 1);
AsyncDuplexStreamingCall<StreamingMessage, StreamingMessage> _call;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace Microsoft.Azure.Functions.PowerShellWorker.Utility
{
public class RpcLogger : ILogger
internal class RpcLogger : ILogger
{
FunctionMessagingClient _client;
string _invocationId = "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace Microsoft.Azure.Functions.PowerShellWorker.PowerShell
{
using System.Management.Automation;

public static class PowerShellWorkerExtensions
internal static class PowerShellWorkerExtensions
{
// This script handles when the user adds something to the pipeline.
// It logs the item that comes and stores it as the $return out binding.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace Microsoft.Azure.Functions.PowerShellWorker.Requests
{
using System.Management.Automation;

public static class HandleFunctionLoadRequest
internal static class HandleFunctionLoadRequest
{
public static StreamingMessage Invoke(
PowerShell powershell,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace Microsoft.Azure.Functions.PowerShellWorker.Requests
{
using System.Management.Automation;

public static class HandleInvocationRequest
internal static class HandleInvocationRequest
{
public static StreamingMessage Invoke(
PowerShell powershell,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Microsoft.Azure.Functions.PowerShellWorker.Requests
{
using System.Management.Automation;

public static class HandleWorkerInitRequest
internal static class HandleWorkerInitRequest
{
public static StreamingMessage Invoke(
PowerShell powershell,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace Microsoft.Azure.Functions.PowerShellWorker.Utility
{
public static class TypeExtensions
internal static class TypeExtensions
Copy link
Member

Choose a reason for hiding this comment

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

This is more of a style thing I suppose but internal is redundant here and can be removed. I've typically been following along with what Visual Studio has told me to do which complains:

screen shot 2018-08-28 at 10 19 03 pm

Ideally we should turn on StyleCop or something.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I know "internal" is the default modifier for a class and private is the default for a member, but it's better to always specify the modifier explicitly.

{
static HttpRequestContext ToHttpRequestContext (this RpcHttp rpcHttp)
{
Expand Down
6 changes: 6 additions & 0 deletions src/Azure.Functions.PowerShell.Worker/Worker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@

namespace Microsoft.Azure.Functions.PowerShellWorker
{
/// <summary>
/// The PowerShell language worker for Azure Function
/// </summary>
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for adding the comments! :)

public static class Worker
{
static readonly FunctionLoader s_functionLoader = new FunctionLoader();
Expand Down Expand Up @@ -49,6 +52,9 @@ static void InitPowerShell()
s_ps.Commands.Clear();
}

/// <summary>
/// Entry point of the language worker.
/// </summary>
public async static Task Main(string[] args)
{
WorkerArguments arguments = null;
Expand Down