I've probably missed an extremely obvious setting, but no matter what I try, I can't get ReSharper to apply any type layout (neither my own nor the default ones).
(using ReSharper 10.0.0.2 Ultimate trial)
I just made a quick type layout in the visual designer, this is the generated XAML:
<?xml version="1.0" encoding="utf-16"?>
<Patterns xmlns="urn:schemas-jetbrains-com:member-reordering-patterns">
<TypePattern DisplayName="Default">
<Entry DisplayName="Fields">
<Entry.Match>
<Kind Is="Field" />
</Entry.Match>
</Entry>
<Entry DisplayName="Methods">
<Entry.Match>
<Kind Is="Method" />
</Entry.Match>
</Entry>
</TypePattern>
</Patterns>
I always did a full code cleanup, but even with a custom profile (as seen below, only "apply file template" selected) nothing is reordered:
Edit:
It seems Resharper did move certain things in some files of my project, but by no means were all fields/methods (no matter what access or static) put in the right order.
Turns out it indeed was something obvious. Apparently the regions in code (despite they grouped methods/properties already) prevented the layout from being applied.
Related
I have a custom File Layout Type Pattern that formats my source files according to a specific set of preferences I defined. The formatting is applied automatically when I run code cleanup.
The problem I have is this: for structs that I use for P/Invoke the order of the members is important. How can I get ReSharper to ignore applying my File Layout Type Pattern for structs?
I think a previous version of ReSharper used to have this but in ReSharper 2017, I can't seem to figure out how to do it. Any suggestions?
In out-of-the-box File Layout, there is a special Pattern named "Non-recordable types", which does exactly what you want to reach:
It has "Struct" type inside and the main pattern won't touch any entity matched by this pattern.
It seems like your custom File Layout does not have such pattern.
However, you might add the following XML code to <Patterns> tag in Options to get it back (ReSharper | Options | Code Editing | C# | File Layout | XAML button at the top)
<TypePattern DisplayName="Non-reorderable types">
<TypePattern.Match>
<Or>
<And>
<Kind Is="Interface" />
<Or>
<HasAttribute Name="System.Runtime.InteropServices.InterfaceTypeAttribute" />
<HasAttribute Name="System.Runtime.InteropServices.ComImport" />
</Or>
</And>
<Kind Is="Struct" />
<HasAttribute Name="JetBrains.Annotations.NoReorderAttribute" />
<HasAttribute Name="JetBrains.Annotations.NoReorder" />
</Or>
</TypePattern.Match>
</TypePattern>
I am on NLog 4.3.5.
I have a long, complicated layout string that I want to save in a <variable /> for use in four layout attributes. Unfortunately, if I refer to the variable using
layout="${layout_full}"
then NLog complains that it cannot find that layout formatter (even though it isn't a layout formatter, it's a variable); and if I refer to the variable using
layout="${var:layout_full}"
then the layout evaluates to a blank string.
In other words, this:
<variable name="layout-full" value="
${longdate} [${level}] ${logger} ${all-event-properties}${newline}
${message}
${when:when='${exception}'!='':inner=
${newline}${exception}
${newline}${stacktrace}}
" />
<target name="stdout" xsi:type="Console" error="false" layout="a${var:layout-full}b" />
shows all log entries as "ab".
I have also tried putting all four targets into a SplitGroup and applying a layout to the group, but that's apparently unsupported.
Not sure if this is the case here, but the <variable> should be outside the <target> and <targets>
I'm currently creating some list definition for use in a SharePoint 2010 environment. In these definitions I need to to define a view which enables in-line editing. This is easily accomplished in the UI as well as from code by setting the InLine property of the SPView object to "TRUE", however I can't find any property of the CAML definition of the view to set the property.
I've looked at what Visual Studio supplies in the auto-complete for both attributes of the element and immediate children of the same element and nothing seems to be relevant.
Anyone know if I'm looking in the entirely wrong place, or have any idea where to set this in the schema.xml of the list definition?
You can enable Inline Editing in the View element of the List definition (Schema.xml) by defining the InlineEdit element and giving it a value of TRUE, like so:
<View ...>
<ViewFields ... />
<Query ... />
<Aggregations Value="Off" />
<RowLimit Paged="TRUE">30</RowLimit>
<Mobile ... />
<InlineEdit>TRUE</InlineEdit>
<Toolbar Type="Standard" />
<XslLink Default="TRUE">main.xsl</XslLink>
<ParameterBindings>
<ParameterBinding Name="NoAnnouncements" Location="Resource(wss,noXinviewofY_LIST)" />
<ParameterBinding Name="NoAnnouncementsHowTo" Location="Resource(wss,noXinviewofY_DEFAULT)" />
</ParameterBindings>
</View>
On a Quick Note,In SharePoint 2010 CAML Based view is obsolete. Though CAML based view will work in 2010 it will not be support for the next version of SharePoint. Considering that you are developing new List Definition IMHO I recommand to look in to the XSLT based views and see if you could get your requirement work in the XSLT.
CAML Obsolete & View is based on XSLT
CAML Reference
I've got a customized clean-up and it's almost 'there'.
However, R# appears to want to sort the member methods, but at least it does not appear to be alphabetically.
Is there a way to force that sorting?
Customizing the layout can indeed be accomplished with Resharper. Go to:
Resharper->Options->Languages->C#->Formatting Style->Type Members Layout
ReSharper 2017
Resharper -> Options-> Code Editing -> C# -> File Layout -> Interface Implementations/All Other Members
and uncheck the "Use Default Patterns" option.
Now you'll want to edit the xml in the "Custom Patterns" box. I'd recommend copying it out to an editor that can properly hi-light the xml (notepad++ or visual studio should work fine).
Now, find the section near the bottom:
<!--all other members-->
<Entry/>
and change it to:
<!--all other members-->
<Entry>
<Match>
<Kind Is="method"/>
</Match>
<Sort>
<Name/>
</Sort>
</Entry>
Now, make sure that your cleanup profile has "Reorder type members", and then right click on the filename in solution explorer and do "Cleanup code...". I've just tried this myself and it does order the methods alphabetically.
If you want to also sort by access type, you can add this under the <Sort> element:
<Access Order="public protected internal private" />
Here's an article to learn more.
Resharper->Options->Languages->C#->File Layout
Select "All other members" and select "Sort by name" (highlighted in bottom right of pic)
In the XML file layout you have to add the element Entry.SortBy
For example in All other members:
<Entry DisplayName="All other members">
<Entry.SortBy>
<Name />
</Entry.SortBy>
</Entry>
The problem with the 9.2 is that when the Entry.SortBy is missing from XML the selected value from the designer is not saved.
I'm trying to deploy multiple web parts as part of the same feature. SharePoint itself seems to do this quite happily by specifying multiple File elements in a single Module element (see C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES\SearchWebParts); in my case, only the first web part is added to the Web Parts gallery, albeit to the Miscellaneous group instead of the group specified in the Property element.
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Module Name="WebPartPopulation" Url="_catalogs/wp" Path="WebParts">
<File Url="Test1.webpart" Type="GhostableInLibrary">
<Property Name="Group" Value="MyGroup" />
</File>
<File Url="Test2.webpart" Type="GhostableInLibrary">
<Property Name="Group" Value="Mygroup" />
</File>
</Module>
</Elements>
My .webpart files are located in the same directory as the elements file; I tried setting Path="" on the Elements element but nothing gets deployed then. Switching around the two File elements deploys Test2.webpart instead of Test1 and Test1.webpart is not added on feature activation. Adding a single File per Module does work but that means duplicating the Module elements.
I'm self-closing the Property elements but that's surely not a sin?? What am I doing wrong?
The above would seem to be correct: after a reboot and a sleep, both web parts ended up in their proper groups when I came back to it the next day. It's surprising how often I find a reboot fixes up weird SharePoint things like this that even and iisreset won't touch. Maybe other services that should be reset/caching these things?