Skip to content

Commit

Permalink
MSBuildEvaluator timeout breaks right-click + publish #611
Browse files Browse the repository at this point in the history
  • Loading branch information
maartenba committed Jul 13, 2022
1 parent ccc48d2 commit 7383f19
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<ul>
<li>Azure Functions: Deployment slots not appearing in the IDE (<a href="https://github.com/JetBrains/azure-tools-for-intellij/issues/596">#596</a>)</li>
<li>Azure Functions: Can't debug from gutter mark in some v4 projects (<a href="https://github.com/JetBrains/azure-tools-for-intellij/issues/602">#602</a> / <a href="https://youtrack.jetbrains.com/issue/RIDER-78053">RIDER-78053</a>)</li>
<li>MSBuildEvaluator timeout breaks right-click + publish (<a href="https://github.com/JetBrains/azure-tools-for-intellij/issues/611">#611</a>)</li>
</ul>
</html>
]]>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2020-2021 JetBrains s.r.o.
// Copyright (c) 2020-2022 JetBrains s.r.o.
//
// All rights reserved.
//
Expand All @@ -18,20 +18,31 @@
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

using System.Linq;
using JetBrains.Lifetimes;
using JetBrains.ProjectModel;
using JetBrains.ProjectModel.MSBuild;
using JetBrains.ProjectModel.Properties;
using JetBrains.Rd.Tasks;
using JetBrains.RdBackend.Common.Features;
using JetBrains.ReSharper.Resources.Shell;
using JetBrains.Rider.Azure.Model;
using JetBrains.Util;

namespace JetBrains.ReSharper.Azure.Daemon.FunctionApp
{
[SolutionComponent]
public class FunctionAppDaemonHost
{
private readonly ISolution _solution;
private readonly FunctionAppDaemonModel _model;

public FunctionAppDaemonHost(ISolution solution)
{
_solution = solution;

_model = solution.GetProtocolSolution().GetFunctionAppDaemonModel();
_model.GetAzureFunctionsVersion.Set(GetAzureFunctionsVersionHandler);
}

public void RunFunctionApp(string methodName, string functionName, string projectFilePath)
Expand All @@ -48,5 +59,17 @@ public void TriggerFunctionApp(string methodName, string functionName, string pr
{
_model.TriggerFunctionApp(new FunctionAppRequest(methodName, functionName, projectFilePath));
}

private RdTask<string> GetAzureFunctionsVersionHandler(Lifetime lifetime, AzureFunctionsVersionRequest request)
{
using (ReadLockCookie.Create())
{
var project = _solution.FindProjectByProjectFilePath(VirtualFileSystemPath.Parse(request.ProjectFilePath, InteractionContext.SolutionContext));

var azureFunctionsVersion = project?.GetRequestedProjectProperties(MSBuildProjectUtil.AzureFunctionsVersionProperty).FirstOrDefault();

return RdTask<string>.Successful(azureFunctionsVersion);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ object FunctionAppDaemonModel : Ext(SolutionModel.Solution) {
field("projectFilePath", string)
}

private val AzureFunctionsVersionRequest = structdef {
field("projectFilePath", string)
}

init {
setting(Kotlin11Generator.Namespace, "com.jetbrains.rider.azure.model")
setting(CSharp50Generator.Namespace, "JetBrains.Rider.Azure.Model")
Expand All @@ -73,5 +77,8 @@ object FunctionAppDaemonModel : Ext(SolutionModel.Solution) {

sink("triggerFunctionApp", FunctionAppRequest)
.doc("Signal from backend to trigger a Function App.")

call("getAzureFunctionsVersion", AzureFunctionsVersionRequest, string.nullable)
.doc("Request from frontend to read the AzureFunctionsVersion MSBuild property.")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
<ul>
<li>Azure Functions: Deployment slots not appearing in the IDE (<a href="https://github.com/JetBrains/azure-tools-for-intellij/issues/596">#596</a>)</li>
<li>Azure Functions: Can't debug from gutter mark in some v4 projects (<a href="https://github.com/JetBrains/azure-tools-for-intellij/issues/602">#602</a> / <a href="https://youtrack.jetbrains.com/issue/RIDER-78053">RIDER-78053</a>)</li>
<li>MSBuildEvaluator timeout breaks right-click + publish (<a href="https://github.com/JetBrains/azure-tools-for-intellij/issues/611">#611</a>)</li>
</ul>
<p>[3.50.0-2022.1]</p>
<ul>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,27 +23,16 @@
package org.jetbrains.plugins.azure.functions.coreTools

import com.intellij.openapi.project.Project
import com.jetbrains.rdclient.util.idea.pumpMessages
import com.jetbrains.rider.run.environment.MSBuildEvaluator
import org.jetbrains.concurrency.isPending
import java.time.Duration
import com.jetbrains.rd.framework.impl.RpcTimeouts
import com.jetbrains.rider.azure.model.AzureFunctionsVersionRequest
import com.jetbrains.rider.azure.model.functionAppDaemonModel
import com.jetbrains.rider.projectView.solution

object FunctionsCoreToolsMsBuild {

const val PROPERTY_AZURE_FUNCTIONS_VERSION = "AzureFunctionsVersion"

fun requestAzureFunctionsVersion(project: Project, projectFilePath: String): String? {

val msBuildEvaluator = MSBuildEvaluator.getInstance(project)

val msBuildPropertiesPromise = msBuildEvaluator.evaluateProperties(
MSBuildEvaluator.PropertyRequest(projectFilePath, null, listOf(PROPERTY_AZURE_FUNCTIONS_VERSION)))

pumpMessages(Duration.ofSeconds(15)) { !msBuildPropertiesPromise.isPending }

val msBuildProperties = msBuildPropertiesPromise.blockingGet(0)
?: return null

return msBuildProperties[PROPERTY_AZURE_FUNCTIONS_VERSION]
}
fun requestAzureFunctionsVersion(project: Project, projectFilePath: String): String? = project.solution.functionAppDaemonModel
.getAzureFunctionsVersion
.sync(AzureFunctionsVersionRequest(projectFilePath), RpcTimeouts.default)
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ import com.jetbrains.rider.model.debuggerWorker.DebuggerStartInfoBase
import com.jetbrains.rider.model.debuggerWorker.DotNetCoreAttachSuspendedStartInfo
import com.jetbrains.rider.run.dotNetCore.DotNetCoreAttachProfileState
import com.jetbrains.rider.runtime.RunningAssemblyInfo
import org.jetbrains.concurrency.Promise
import org.jetbrains.concurrency.resolvedPromise

class AzureFunctionsDotNetCoreAttachSuspendedProfileState(
private val runtime: AzureFunctionsDotNetCoreRuntime,
Expand Down

0 comments on commit 7383f19

Please sign in to comment.