Skip to content

Commit

Permalink
- CLI: webapi sample update (2)
Browse files Browse the repository at this point in the history
  • Loading branch information
oleg-shilo committed Jan 14, 2023
1 parent 0ebdce3 commit 991c492
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
8 changes: 7 additions & 1 deletion src/cscs/HelpProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1327,8 +1327,10 @@ static SampleInfo[] CSharp_command_Sample(string context)

static SampleInfo[] CSharp_webipi_Sample(string context, bool addOpenApi)
{
// using roslyn engine seems also possible but it will require manually referencing all asp.core assemblies
var cs =
@"//css_webapp
//css_ng csc
$extrapackages$//css_nuget Swashbuckle.AspNetCore
//css_inc global-usings
using Microsoft.AspNetCore.Builder;
Expand All @@ -1347,7 +1349,11 @@ static SampleInfo[] CSharp_webipi_Sample(string context, bool addOpenApi)
.UseHttpsRedirection()
.UseStaticFiles();
app.MapGet(""/test"", (HttpRequest request) => new { Name = ""Test Response"" })$extracode$;
app.MapGet(""/test"", (HttpRequest request) => new
{
Name = ""Test Response"",
Time = Environment.TickCount;
})$extracode$;
app.Run();
";
Expand Down
8 changes: 3 additions & 5 deletions src/cscs/Models/BuildResult.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Emit;

// using Microsoft.CodeAnalysis.Emit;
using System.Collections.Generic;
using System.Linq;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Emit;

namespace csscript
{
Expand All @@ -28,7 +26,7 @@ public static BuildResult.Diagnostic From(Microsoft.CodeAnalysis.Diagnostic data
Location_IsInSource = data.Location.IsInSource,
Location_StartLinePosition_Line = data.Location.GetLineSpan().StartLinePosition.Line,
Location_StartLinePosition_Character = data.Location.GetLineSpan().StartLinePosition.Character,
Location_FilePath = data.Location.SourceTree.FilePath,
Location_FilePath = data.Location.SourceTree?.FilePath,
Id = data.Id,
Message = data.GetMessage()
};
Expand Down
2 changes: 1 addition & 1 deletion src/cscs/NuGet.Core.cs
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ static string GetPackageCompatibleLib(PackageInfo package)
else // host runtime
{
if (Runtime.IsCore)
return (frameworks.FirstOrDefault(x => x.Runtime.StartsWith("net", ignoreCase: true))
return (frameworks.FirstOrDefault(x => x.Runtime.StartsWith("netcore", ignoreCase: true))
?? frameworks.FirstOrDefault(x => x.Runtime.StartsWith("netstandard", ignoreCase: true)))?.Path;
else
return frameworks.FirstOrDefault(x => x.Runtime.StartsWith("net", ignoreCase: true)
Expand Down

0 comments on commit 991c492

Please sign in to comment.