Rui Silva582855

Hi.

I'm facing some issues using the DSL Integration Service.

My goal for now is simple as referencing one instance of the minimal language (Language1) from within another instance of another minimal language (Language2).

Here the steps that i followed trying to achieve my goal:

1. I've marked Language1 as exportable as you can see in the following code

namespace Company.Language1

{

/// <summary>

/// Double-derived class to allow easier code customization.

/// </summary>

/// <remarks>

/// A package load key is required to allow this package to load when the Visual Studio SDK is not installed.

/// Package load keys may be obtained from http://msdn.microsoft.com/vstudio/extend.

/// Consult the Visual Studio SDK documentation for more information.

/// [VSShell:Stick out tonguerovideLoadKey("Standard", Constants.ProductVersion, Constants.ProductName, Constants.CompanyName, 1)]

/// </remarks>

[VSShell::ProvideMenuResource(1000, 1)]

[VSShell::ProvideToolboxItems(1)]

[VSTextTemplatingHost::ProvideDirectiveProcessor(typeof(global::Company.Language1.Language1DirectiveProcessor), global::Company.Language1.Language1DirectiveProcessor.Language1DirectiveProcessorName, "A directive processor that provides access to Language1 files")]

[global:Tongue Tiedystem.Runtime.InteropServices.Guid(Constants.Language1PackageId)]

[Microsoft.VisualStudio.Modeling.Integration.RegisterAsExportable(

typeof(Language1DomainModel),

typeof(Language1SerializationBehaviorMonikerResolver),

typeof(ExampleModel),

typeof(Language1SerializationBehavior))]

internal sealed partial class Language1Package : Language1PackageBase

{

}

}

2. In the other DSL (Language2), in the ExampleShape.OnDoubleClick() I'm implementing the following code:

using System;

using System.Collections.Generic;

using System.Text;

using Microsoft.VisualStudio.Modeling.Diagrams;

using Microsoft.VisualStudio.Modeling.Integration;

using System.Collections.ObjectModel;

namespace Company.Language2

{

public partial class ExampleShape

{

public override void OnDoubleClick(DiagramPointEventArgs e)

{

// get VS DSL integration service

IDslIntegrationService service = (IDslIntegrationService)Store.GetService(typeof(IDslIntegrationService));

// get a domain model browser for a given dsl namespace

IDomainModelBrowser domainModelBrowser = service.GetDomainModelBrowser("Company.Language1");

ReadOnlyCollection<ExportedClass> x = domainModelBrowser.FindAllClasses();

object y = domainModelBrowser.FindAllInstances(x[1]);

base.OnDoubleClick(e);

}

}

}

Results:

I can get a list of all the exported classes by calling the FindAllClasses() method but I can't get all instances of a given class (by calling the FindAllInstances() method)!! It always return zero elements. Any Idea



Re: Visual Studio Extensibility Issues using DSL Integration Service

Edward Bakker

Hi,

I have tried your example code and it works fine in my environment. I assume in your case "x[1]" refers to the "ExampleElement" class referencing another class might return an error because of a missing "IsElementName= true" property.

Another option, does your file contain a "saved" ExampleElement I am asking because when I first tested this I simply added an ExampleElement (shape) to the designer

and double clicked the shape without saving the model first. X was populated fine but y (in your example) wasn't. This was obviously becuase the model wasn't saved.

Edward





Re: Visual Studio Extensibility Issues using DSL Integration Service

Rui Silva

Thanks Edward for your time.

X[1] refers indeed to the ExampleElement class.

By default the minimal language contains one file named Sample.mydsl which already contains two ExampleElement Shapes on it. So my target language, Language1, which resides in another DSL project solution does have a saved file called Sample.mydsl3 with two ExampleElement shapes on it.

Just to make it clear I'm trying to reference a target DSL (Language1) from another DSL (Language2). These are in fact two different DSLs.

For sure I'm missing something Sad





Re: Visual Studio Extensibility Issues using DSL Integration Service

Rui Silva

Do you have any clue about what the problem could be

Thanks,

Rui





Re: Visual Studio Extensibility Issues using DSL Integration Service

Edward Bakker

Rui,

Ok, I have tested this again, this time with two languages and everything seems to work just fine.

Here is what I did:

I created two languages: Language1 and Language2 (Language2 is exportable). In Language1 I implemented a custom command and added your code but only changed the "x[1]" to make sure it reflects the "ExampleClass" (in language 2) and changed the namespace in the "GetDomainModelBrowser" line to reflect the namespace of Language2. After that, I compiled both languages and debugged Language1. I added a Language2 to model to the Language1 debug solution and executed the custom command in Language1 (to extecute your code).

For me everything works fine. Is there something you did different

Edward





Re: Visual Studio Extensibility Issues using DSL Integration Service

Rui Silva

Hi Edward, I don't understand what you mean with "I added a Language2 to model to the Language1 debug solution ..."



Re: Visual Studio Extensibility Issues using DSL Integration Service

Edward Bakker

ok, sorry. I mean, when debugging Language1 (in the debug solution) I do "add new item" and select the Language2 template to create a new Language2 model in the debug solution. I add some elements to the Language2 model and save it. It is this model and the elements that are the instances I see in "y" in your example.

Edward





Re: Visual Studio Extensibility Issues using DSL Integration Service

Rui Silva

Finally Smile That was the piece I was missing.

I was triying to reference a model that wasn't in current debug solution. Isn't this a supported scenario I think that i some cases it would be usefull to reference some assembly with some model defined on it.

Anyway for now i satisfied. Thanks Edward.





Re: Visual Studio Extensibility Issues using DSL Integration Service

Edward Bakker

Rui,

great news! DIS reflects on the available model files (Language2.mydsl) in the current solution and gets all instances available in these model files.

Edward





Re: Visual Studio Extensibility Issues using DSL Integration Service

Kishore Gopalan

I'm not able to find the Microsoft.VisualStudio.Modeling.Integration namespace. Is this part of the standard DSL Tools installed with VS SDK Or should I add it from elsewhere

Any pointers to sample implementations of DSL Integration will be very useful.

TIA

Kishore





Re: Visual Studio Extensibility Issues using DSL Integration Service

Kishore Gopalan

Got it.

I guess it is the same as this. Any pointers to application samples on getting started with DIS will be very helpful.

TIA

Kishore





Re: Visual Studio Extensibility Issues using DSL Integration Service

Edward Bakker

Hi,

DIS comes with a (small) document that explains how to use it. You will find it in the install directory after installing DIS on your machine. Also, you might want to have a look a this article at MSDN site that covers DIS.

Edward





Re: Visual Studio Extensibility Issues using DSL Integration Service

Kishore Gopalan

Hi,

I'm not able to find Microsoft.VisualStudio.Modeling.Integration assembly with the DIS instllation, and the DslPackage.csproj present in the DIS sample is not opening, gives an error - "The imported project C:\Program Files\Microsoft Visual Studio 2005 SDK\2006.09\VisualStudioIntegration\Tools\Build\Microsoft.VsSDK.targets" was not found. Confirm that the path in the <import> declaration is correct, and that the file exists on disk"

Please let me know, if I'm missing something.

TIA

Kishore





Re: Visual Studio Extensibility Issues using DSL Integration Service

Edward Bakker

Hi,

You should find the assembly in the "C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\PublicAssemblies" folder. I think you are running VS SDK 4.0 on your machine, so the "2006.09" part in the imported project link should be "2007.02" you can change this manualy by opening the "DslPackage.csproj" file in notepad (for example)

Hope this helps

Edward





Re: Visual Studio Extensibility Issues using DSL Integration Service

Kishore Gopalan

Hi,

I have a model, with a domain property (say, P) of a domain class set to the following custom attributes.

[Microsoft.VisualStudio.Modeling.Integration.TargetClass(@"CompanyName.BizModel\FlowElement")]

[System.ComponentModel.Editor(typeof(Microsoft.VisualStudio.Modeling.Integration.Editors.ExportedClassEditor),typeof(System.Drawing.Design.UITypeEditor))]

[System.ComponentModel.TypeConverter(typeof(Microsoft.VisualStudio.Modeling.Integration.ExportedInstanceConverter))]

And it's package class is marked exportable.

Code Snippet

[RegisterAsExportable(typeof(BizModelDomainModel),

typeof(BizModelSerializationBehaviorMonikerResolver),

typeof(FlowGraph),

typeof(BizModelSerializationBehavior))]

internal sealed partial class BizModelPackage

{

}

I run the model to open the Debudding solution. The propery P appears with a default value "mel://" and when I click on the "..." button to open the property page I get this error.

Package Load Failure. Package 'Microsoft.VisualStudio.Modeling.Integration.DslIntegrationPackage,Microsoft.VisualStudio.Modeling.Integration, Version=8.2.0.0,Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' had failed to load propery ( GUID ={E7A6F5A1-596D-4325-BBF5-6127A0925F72}). Please contact package vendor for assistance.

I tried adding a reference to the Microsoft.VisualStudio.Modeling.Integration assembly in the Debugging solution, but of no avail.

Am I missing something

TIA

Kishore