File Layout: Matching field targeted attributes on auto-properties - unity3d

In newer versions of Unity you can serialize the backing fields of properties via this pattern:
[field: SerializeField]
public Sprite Sprite { get; private set; }
Is there any way to specifically match on properties that have field targeted attributes in the File Layout settings of Rider? I've tried a few different things but none of them seem to result in a match:
<Entry DisplayName="Serialized Properties" Priority="150">
<Entry.Match>
<And>
<unity:SerializedField/>
<Kind Is="Autoproperty" />
</And>
</Entry.Match>
</Entry>
<Entry DisplayName="Serialized Properties" Priority="150">
<Entry.Match>
<And>
<HasAttribute Name="SerializeField"/>
<Kind Is="Autoproperty" />
</And>
</Entry.Match>
</Entry>
<Entry DisplayName="Serialized Properties" Priority="150">
<Entry.Match>
<And>
<HasAttribute Name="field: SerializeField"/>
<Kind Is="Autoproperty" />
</And>
</Entry.Match>
</Entry>

As of Rider 2022.1, the File Layout settings don't have a way of matching an auto property with a field: targeted attribute - the HasAttribute element will only match attributes that target the property itself. Here's an issue you can vote for and track: RSRP-488346.

Related

How to assign two different types to the same tagged value?

How can i assign two different types to the same tagged value in MDG.
For Example:- There's a tagged value with the name TAG1 whose type is
Type=String; and also Type=RefGUID;. Now how to make this tag properties attain both the types i.e., It should be of string as well as RefGUID.
Definitely this is not possible. The XMI profile for a tagged value looks like this (taken from the White Board Circle):
<TaggedValues>
<Tag name="fill" type="boolean" description="" unit="" values="true,false" default="false"/>
<Tag name="nameVisible" type="boolean" description="" unit="" values="true,false" default="false"/>
</TaggedValues>
If you add a duplicate tagged value for fill, only the first will be visible. So instead of a boolean you now see an int, but not both.
<TaggedValues>
<Tag name="fill" type="int" description="" unit="" values="1,2" default="1"/>
<Tag name="fill" type="boolean" description="" unit="" values="true,false" default="false"/>
<Tag name="nameVisible" type="boolean" description="" unit="" values="true,false" default="false"/>
</TaggedValues>
Conclusion: do as I commented. Name them differently.

Mybatis Generator's bug: configuration items should be ordered?

If I put "<commentGenerator>" after "<jdbcConnection>", MBG proposed an error that context content should match: blablabla...
But when I put "<commentGenerator>" before "<jdbcConnection>", everything is ok. Here I have something to complain to the official website that if the order of these items is need, why you do not tell us! What an important thing! You r kidding the freshmen. Maybe it is some where I do not know, but this is a key point to build the MBG's configuration file successfully, why not put this NOTE on the top of the tutorial or somewhere eye-catching?
<generatorConfiguration >
<classPathEntry location="D:\mariadb-java-client-1.1.7.jar" />
<context id="db" >
<commentGenerator>
<property name="suppressAllComments" value="true" />
<property name="suppressDate" value="true" />
</commentGenerator>
<jdbcConnection driverClass="org.mariadb.jdbc.Driver"
connectionURL="jdbc:mariadb://localhost:3306/dbname"
userId="root"
password="password"
/>
<javaTypeResolver >
<property name="forceBigDecimals" value="false" />
</javaTypeResolver>
<!-- Model Class -->
<javaModelGenerator targetPackage="org.infrastructure.model" targetProject="infrastructure\src\main\java">
<property name="enableSubPackages" value="false" />
<property name="trimStrings" value="true" />
</javaModelGenerator>
<!-- XML Files -->
<sqlMapGenerator targetPackage="sqlMap" targetProject="infrastructure\src\main\config">
<property name="enableSubPackages" value="false" />
</sqlMapGenerator>
<!-- DAO -->
<javaClientGenerator type="XMLMAPPER" targetPackage="org.infrastructure.dao" targetProject="infrastructure\src\main\java">
<property name="enableSubPackages" value="false" />
</javaClientGenerator>
<!-- Tables -->
<table tableName="user" domainObjectName="User" ></table>
</context>
</generatorConfiguration>
First of all, in your xml configuration file, it doesn't contains a valid root element, which always should be like <!DOCTYPE .../>. About how to add a correct root element of mybatis generator configuration file, please see example from MyBatis GeneratorXML Configuration File Reference.
If you correctly specified root element such as following:
<!DOCTYPE generatorConfiguration PUBLIC
"-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
"http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd"
>
This root element contains a typical DTD declaration located at http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd. This is the definition of the order of these items is need. And we are going to see what it looks like.
From line 47 of this document type definition, it defines element named context. The content is as following:
<!--
The context element is used to describe a context for generating files, and the source tables.
-->
<!ELEMENT context (property*, plugin*, commentGenerator?, jdbcConnection, javaTypeResolver?,javaModelGenerator, sqlMapGenerator?, javaClientGenerator?, table+)>
Which obviously defined the order of the element in context, that is:
property*, plugin*, commentGenerator?, jdbcConnection,
javaTypeResolver?,javaModelGenerator, sqlMapGenerator?,
javaClientGenerator?, table+
In this element, all children must occurs as following rules:
+ for specifying that there must be one or more occurrences of the item — the effective content of each occurrence may be different;
* for specifying that any number (zero or more) of occurrences is allowed — the item is optional and the effective content of each occurrence may be different;
? for specifying that there must not be more than one occurrence — the item is optional;
If there is no quantifier, the specified item must occur exactly one time at the specified position in the content of the element.
After we understanding its real meaning, why you could not change the order of commentGenerator and jdbcConnection should be clear.
Maybe you want to know how to make the element out of order, question How to define DTD without strict element order could be useful.
Wish it helpful.

Entity Framework designer custom property does not appear in DDL generation

I have added a custom property to the Properties dialog of the Entity Framework 5 designer through
http://msdn.microsoft.com/en-us/library/microsoft.data.entity.design.extensibility.ientitydesignerextendedproperty(v=vs.103).aspx
This works well, the property appears in the Properties dialog and it is saved in the EDMX file.
Now I'd like to use that property in the DDL generation process. I have edited the T4 template file SSDLToSQL10.tt (found at C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\Extensions\Microsoft\Entity Framework Tools\DBGen).
However, the custom property doesn't seem to appear anywhere in the metadata tree. The website (in German)
http://www.databinding.net/en/blog/post/2010/12/13/entity-framework-4-erweiterte-eigenschaften-in-einer-t4-vorlage-verwenden.html
tells me that the extended property should appear in the EntityType.MetadataProperties collection, but this collection contains only the following members:
KeyMembers Members Name NamespaceName Abstract BaseType DataSpace MetadataProperties
None of those is my custom property.
Am I missing something? How can I access the IEntityDesignerExtendedProperty's value in the T4 code generation template?
EDIT: Here is the EDMX part with the custom property:
<edmx:ConceptualModels>
<Schema ...>
....
<EntityType Name="Entity1">
<Key>
<PropertyRef Name="Id" />
</Key>
<Property Type="Guid" Name="Id" Nullable="false" annotation:StoreGeneratedPattern="None" />
<Property Type="String" Name="Name" Nullable="false" />
<a:MyNewProperty xmlns:a="http://schemas.tempuri.com/MyNewProperty">True</a:MyNewProperty>
</EntityType>
I guess I have to map that custom property from CSDL to SSDL somehow.
You added the property to the CSDL (conceptual layer) while the DDL is created using the SSDL (store layer). You should be able to access the conceptual model in the SSDLToSQL10.tt but I don't think it is really what you are after. In general your property is not something the EF runtime can really use - I believe it will be just treated as an extension and ignored. If you want to add a property that is supposed to be used by the EF runtime the property must be declared in the CSDL (conceptual layer) and SSDL (store layer) and mapped correctly in the MSL (mapping layer) - with the latter being probably the most difficult.
Unless I am missing what you are trying to achieve you are probably using a wrong extension point. The IEntityDesignerExtendedProperty allows defining custom properties that shows in the property and the model browser windows in the designer but are ignored at runtime. For me it looks like you would like to add a property automatically to your model. For that I would try using the IModelTransformationExtension where you should be given the entire edmx which you will be able to modify at will (i.e. CSDL, SSDL, MSL and add elements (properties) in correct EF xml namespaces). I would try using OnBeforeModelSaved since I believe the model will be saved automatically before trying to generate the database.
I was able to achieve what I want using the edmx:CopyToSSDL=true attribute:
<edmx:ConceptualModels>
<Schema ...>
....
<EntityType Name="Entity1">
<Key>
<PropertyRef Name="Id" />
</Key>
<Property Type="Guid" Name="Id" Nullable="false" annotation:StoreGeneratedPattern="None" />
<Property Type="String" Name="Name" Nullable="false" />
<a:MyNewProperty edmx:CopyToSSDL="true"
xmlns:a="http://schemas.tempuri.com/MyNewProperty">
True
</a:MyNewProperty>
</EntityType>
This way, the transformator that generates the SSDL from the CSDL copies the annotation over to the SSDL, so I'm able to access it in the T4 template that generates the DDL SQL file.
If someone is going to use this in Entity Framework 5, please not that there is a bug (http://entityframework.codeplex.com/workitem/702), and you can workaround by using the old EDMX XML namespace:
<a:MyNewProperty edmxv2:CopyToSSDL="true"
xmlns:a="http://schemas.tempuri.com/MyNewProperty"
xmlns:edmxv2="http://schemas.microsoft.com/ado/2008/10/edmx">
True
</a:MyNewProperty>

Checking for null selection variable value in the command framework of Eclipse RCP

How can I check whether the selection variable value is null when I open the editor?
I want to activate a context menu command when the certain editor is opened, it is not dirty and nothing was selected by the user. First two coditions are working fine:
<and>
<with
variable="activePartId">
<equals
value="com.eclipse.someeditor">
</equals>
</with>
<with
variable="activePart">
<not>
<test
property="com.eclipse.isEditorDirty">
</test>
</not>
</with>
<and>
My current problem is that the straightforward solution would be to include another condition:
<with variable="selection">
<count value="0" />
</with>
Unfortunately when the editor is first opened, the count is not 0. It probably is null. If the user selects something and then deselects, it becomes 0. Any ideas how to check whether the value of selection is null or similar?
UPDATE
I also tried creating a property tester that checks whether the value of the selection is null, but the code is not executed. I think that it happens, because it does not even go inside the selection if the user did not select/deselect anything.
<with variable="selection">
<test
property="com.eclipse.isSelectionNullOrEmpty">
</test>
</with>
Try using 'instanceof' and 'and'. Like:
<and>
<instanceof value="fully_qualified_class_name_of_your_selection_class"/>
<equals value="0" />
</and>
Hope this helps.
The following solution worked:
I made the Editor a SelectionProvider that is capable of delegating to another SelectionProvider to be able to switch between them (e.g. when I have an inner table that provides selection as well and take procedence.
Then I set the getSelection() to return an empty StructuredSelection when there is no delegate (opposite to returning null). Thanks to that there is always a StructuredSelection being returned, but sometimes it is empty.
public ISelection getSelection() {
return delegate == null ? new StructuredSelection() : delegate.getSelection();
}
After that I could add the simple condition that I mentioned earlier:
<with variable="selection">
<count value="0" />
</with>
Some people may find this useful.

phing nested if conditions

I am having trouble understanding the Phing documentation regarding multiple conditions for a given <if> tag. It implies you cannot have multiple conditions unless you use the <and> tag, but there are no examples of how to use it. Consequently I nested two <if> tags, however I feel silly doing this when I know there is a better way. Does anyone know how I can use the <and> tag to accomplish the following:
<if><equals arg1="${deployment.host.type}" arg2="unrestricted" /><then>
<if><equals arg1="${db.adapter}" arg2="PDO_MYSQL"/><then>
<!-- Code Here -->
</then></if>
</then></if>
I find it very surprising that no one has had any experience with this. Phing is an implementation of the 'ANT' build tool in PHP instead of Java. It is very useful for PHP developers who feel a lack of a simple and powerful deployment tool. Java's ability to package self contained web projects into a single file or package multiple web project files into a yet bigger file is an amazing capability. ANT or Phing does not get PHP to that point, but its a definite step in the right direction and leaps and bounds easier to understand and use than GNU Make ever was or will be.
According to the Phing documentation:
The <or> element doesn't have any attributes and accepts an arbitrary number of conditions as nested elements. This condition is true if at least one of its contained conditions is, conditions will be evaluated in the order they have been specified in the build file.
It may sound confusing at first, especially with no handy examples available, but the keywords to note are, "accepts an arbitrary number of conditions as nested elements." If you try the following build snippet out, you should easily realize how to use <or> and <and> conditions:
<if>
<or>
<equals arg1="foo" arg2="bar" />
<equals arg1="baz" arg2="baz" />
</or>
<then>
<echo message="Foo equals bar, OR baz equals baz!" />
</then>
</if>
<if>
<or>
<equals arg1="foo" arg2="bar" />
<equals arg1="baz" arg2="bam" />
</or>
<then>
<echo message="Foo equals bar, OR baz equals baz!" />
</then>
<else>
<echo message="No match to OR found." />
</else>
</if>
<fail />