I'm using Rider 2021.3.3 (latest version), and when I have the latest .NET SDK on my machine (.NET 6).
Inside the .editorconfig file, I have added the following:
csharp_namespace_body = file_scoped
When I create a new project, it contains a file with a File-scoped namespace:
namespace ClassLibrary2;
public class Class1
{
}
If I change it to a block-scoped namespace and I run a cleanup, the file doesn't change but remains using the block-scoped namespace.
namespace ClassLibrary2
{
public class Class1
{
}
}
Rider is configured to read settings from the .editorconfig file.
Changing the rules that specifies how much blank lines are required before a single line comment, this is respected.
```csharp_blank_lines_before_single_line_comment = 1`
Any idea on what's going wrong?
Related
By reading my question, you might think its very easy, but i request everyone to try to access a custom field defined in the construction feature package.
I want to access "Type" field in Project screen's Task Tab in details
UsrType is a custom field defined in Construction features package. In that package, file has been converted into dll. I tried to access that field like we usually do in customization.
but i got error
Type or Namespace "PMTaskExt" could not be found
I even tried this
I got error
UsrType Doesn't exist in PMTask
There is also same problem with UsrSubcontractNbr field in APTran. Not Only these fields, there are many such field to be accessed.
How can we access such fields?
From looking at PX.Objects.CN.dll it would be in the PX.Objects.CN.ProjectAccounting.PM.CacheExtensions namespace as PmTaskExt
Used the latest 19R2 Construction project "ConstructionFeatures_19_205_4_1_157"
Decompiled the customization dll (used DotPeek) I searched for PMTask:
Copied text:
using PX.Data;
using PX.Data.BQL;
using PX.Objects.CN.ProjectAccounting.PM.Descriptor;
using PX.Objects.CS;
using PX.Objects.PM;
namespace PX.Objects.CN.ProjectAccounting.PM.CacheExtensions
{
public sealed class PmTaskExt : PXCacheExtension<PMTask>
{
[PXDBString(30)]
[PXDefault]
[PXUIField(DisplayName = "Type", Required = true)]
[ProjectTaskType.List]
public string UsrType { get; set; }
public static bool IsActive()
{
return PXAccess.FeatureInstalled<FeaturesSet.construction>();
}
public abstract class usrType : BqlType<IBqlString, string>.Field<PmTaskExt.usrType>
{
}
}
}
Something like this should work:
var cnExt = PXCache<PX.Objects.PM.PMTask>.GetExtension<PX.Objects.CN.ProjectAccounting.PM.CacheExtensions.PmTaskExt>((PX.Objects.PM.PMTask)e.Row);
Do note the .Net version of PX.Objects.CN.dll is using 4.8 in case that causes any issues with version compatibility in visual studio if your solution is compiled on the same version of Acumatica for 19R2 which is 4.7.1
For my first export script I took the KCEC example and the APIRefExport.chm documentation to create my project by replacing the example code with my own.
I would like to create a clean export script from scratch.
I created a new class library project and called it EmptyExportScript (placeholder). The target framework is .Net 4. The platform target is x86 and the output path is .....\Program Files (x86)\Kofax\CaptureSS\ServLib\Bin\. When debugging I would like to start the administration module so I set this path .......\Program Files (x86)\Kofax\CaptureSS\ServLib\Bin\.
The option "Make assembly COM-Visible" is checked and I added the Kofax.ReleaseLib.Interop.dll to the references.
For the KfxReleaseScript.cs I added this code
[ClassInterface(ClassInterfaceType.None)]
[ProgId("KFXTS.EmptyExportScript.KfxReleaseScript")]
public class KfxReleaseScript
{
public ReleaseData documentData;
// public KfxReturnValue OpenScript()
// public KfxReturnValue ReleaseDoc()
// public KfxReturnValue CloseScript()
}
For the KfxReleaseScriptSetup.cs I added this code
[ClassInterface(ClassInterfaceType.None)]
[ProgId("KFXTS.EmptyExportScript.KfxReleaseScriptSetup")]
public class KfxReleaseScriptSetup
{
public ReleaseSetupData setupData;
// public KfxReturnValue OpenScript()
// public KfxReturnValue CloseScript()
// public KfxReturnValue RunUI()
// public KfxReturnValue ActionEvent(KfxActionValue actionID, string data1, string data2)
}
Lastly I added a Form to the project when running the UI.
For registration I added a EmptyExportScript.inf with this content
[Scripts]
Empty Export
[Empty Export]
SetupModule=EmptyExportScript.dll
SetupProgID=KFXTS.EmptyExportScript.KfxReleaseScriptSetup
SetupVersion=10.2
ReleaseModule=EmptyExportScript.dll
ReleaseProgID=KFXTS.EmptyExportScript.KfxReleaseScript
ReleaseVersion=10.2
SupportsNonImageFiles=True
SupportsKofaxPDF=True
RemainLoaded=True
SupportsOriginalFileName=False
When building the project .dll and .inf file get placed into the kofax bin directory.
I recognized that other scripts have a .pdb and .dll.config file in there too.
How do I get them?
When trying to install the custom script, I can add it to the script installation manager but I can't install it. There is nothing to install so I think I'm missing the .pdb and .dll.config file.
Is anything else missing?
Thanks for help :)
Kofax does not need a pdb file, but they are handy if you want to debug your connector and attach it to the release.exe process (learn more about them here).
I would not recommend changing the output path itself to Capture\Bin, but rather create a post-build event:
For example, the following line copies all required files to a separate folder under the CaptureSS\Bin folder:
xcopy "$(TargetDir)*" "C:\Program Files (x86)\Kofax\CaptureSS\ServLib\Bin\SmartCAP\kec\SmartCAP.KEC.Template\" /Y /S
Having a dll.config file is possible, but rare. I would rather recommend storing process-specific data in a custom storage string object of the respective batch class definition (which has the added benefit that you can just import/export the definition along with the batch class, and that you can display and have it changed it in setup form). Having said all that, back to your initial issue - the connector can't be installed.
COM visibility
The assembly needs to be COM-visible, but you mentioned that it was. For the sake of completeness, here's what you will need to do. Note that the GUID must be unique (only relevant if you copied an existing solution):
If you're installing the connector on a different machine, you will need to register it first using regasm.exe - here's an example:
"C:\Windows\Microsoft.NET\Framework\v4.0.30319\RegAsm.exe" SampleExport.dll /codebase /tlb:SampleExport.tlb
ProgIds
Then, your .inf file needs to contain the precise ProgIDs:
[Scripts]
SampleExport
[SampleExport]
SetupModule=SampleExport.dll
SetupProgID=SampleExport.Setup
SetupVersion=11.0
ReleaseModule=SampleExport.dll
ReleaseProgID=SampleExport
ReleaseVersion=11.0
SupportsNonImageFiles=True
SupportsKofaxPDF=True
Both your ReleaseScript.cs and ReleaseSetupScript.cs files need the correct attribute, for example:
[ProgId("SampleExport")]
public class ReleaseScript
If that all still does not work, please provide us with the detailed error message (to be found at CaptureSV\Logs).
I had to change the file format from UTF-8 to UTF-8 without BOM.
This worked for me.
ReSharper 8.X ships with a macro that fetches the "Containing Type Name", but what I want to do is manipulate that name. I'm using this in a Visual Studio 2013 Web API project, and I want a template that takes the class name and builds the URL that has to be called. So, for example, suppose I have this:
public class AnnouncementController : ApiController
{
//Want to put a template here!
[HttpGet]
public HttpResponseMessage GetActiveAnnouncements()
{
/// ...
}
}
now my ReSharper template will look something like this:
/// This sample shows how to call the <see cref="$METHOD$"/> method of controller $CLASS$ using the Web API.
/// https://myurl.mydomain.com/api/$CONTROLLER$/$METHOD$
$Controller$, by convention, is the class name minus the letters 'Controller'. This is because ASP.NET MVC Web API projects expect classes derived from ApiController to end with the string 'Controller',
Since this class is AnnouncementController, the template should output
https://myurl.mydomain.com/api/Announcement/GetActiveAnnouncements
Resharper's Built-In Macros can give me some of what I need, but I want to write a custom macro that fetches the containing type name and chops "Controller" off of it. I would like to do that directly, without storing the containing type name in another parameter.
Also, how do I install this custom macro? I've Googled around, and all I found was a lot of dead links and old walkthroughs written for ReSharper version 7 and below that do NOT work with ReSharper 8.x
After a lot of fighting, here is my solution.
[MacroImplementation(Definition = typeof (ControllerNameMacroDefinition))]
public class ControllerNameMacroImplementation : SimpleMacroImplementation
{
public ControllerNameMacroImplementation([Optional] IReadOnlyCollection<IMacroParameterValueNew> arguments)
{
}
public override HotspotItems GetLookupItems(IHotspotContext context)
{
var ret = "CONTROLLER";
var fileName = GetFileName(context);
if (!fileName.IsNullOrEmpty())
{
//Replace "Controller.cs" in two separate steps in case the extension is absent
ret = fileName.Replace("Controller", "").Replace(".cs", "");
}
return MacroUtil.SimpleEvaluateResult(ret);
}
/// <summary>
/// Returns the filename of the current hotspot context
/// </summary>
private string GetFileName(IHotspotContext context)
{
var psiSourceFile = context.ExpressionRange.Document.GetPsiSourceFile(context.SessionContext.Solution);
return psiSourceFile == null ? string.Empty : psiSourceFile.Name;
}
}
I wanted to do exactly this, but for JavaScript Jasmine tests -- SomethingViewModel.js, with a fixture of SomethingViewModelFixture.js, but wanted to be able to refer to SomethingViewModel in the file. A few slight modifications to the above made it possible.
Unfortunately, there's a ton more things you need to do in order to get your plugin to actually install. Here's a list. I hope it's comprehensive.
NuGet package install JetBrains.ReSharper.SDK, make sure you have the correct version installed!
Copy your Class Library DLL to C:\Users\<you>\AppData\Local\JetBrains\ReSharper\<version>\plugins\<your plugin name>, creating the plugins directory if needed.
You need the plugin Annotations in your AssemblyInfo.cs file:
[assembly: PluginTitle("Your extensions for ReSharper")]
[assembly: PluginDescription("Some description")] -- this is displayed in ReSharper->Options->Plugins
[assembly: PluginVendor("You")]
You need a class in your project that defines the MacroDefinition, as well as the above MacroImplementation
[MacroDefinition("MyNamespace.MyClassName", ShortDescription = "A short description of what it does.", LongDescription = "A long description of what it does.")]
"ShortDescription" - this is displayed in the "Choose Macro" dialog list.
"LongDescription" you'd think this would be in the "Choose Macro" description, but it isn't.
I just added this annotation to the above file.
The file you add the MacroDefinition to needs to implement IMacroDefinition, which has a method (GetPlaceholder) and a property (Parameters) on it. The former can return any string ("a") and the latter can return an empty array.
You can ignore the WiX/NuGet stuff if you want. Just for a local install.
In VS, the ReSharper->Options->Plugins section has some troubleshooting details on why your plugin might not be loading.
Good luck!
Inside my template file I use the safeitemname template variable to define my class name. The Item Template is intended to create a class that subclasses MXApplication. The result after exporting the template and utilizing it to create a new class is essentially the class inherits from itself. If I try adding a namespace to the class, I just get the namespace prefixed before the value substituted for safeitemname.
Here is the Template class (trimmed for explanation purposes):
namespace $rootnamespace$
{
public class $safeitemname$ : MonoCross.Navigation.MXApplication
{
public override void OnAppLoad()
{
//Do the work
}
}
}
The result when I use the template to create MyApp is:
namespace MyNameSpace
{
public class MyApp : MonoCross.Navigation.MyApp
{
public override void OnAppLoad()
{
//Do the work
}
}
}
I've tried to export this template using VS2012 (and VS2013).
Any advice would be much appreciated. I've been trying to update my Item Templates in Visual Studio 2012 (they worked in 2010) but I keep running into this issue. I've tried it on several of my existing templates; and even tried recreating the .csproj and adding my existing templates to the .csprog file created using Visual Studio 2012. All of my attempts result in the same class inheritance issue.
This is the MSDN Doc I've been using for reference:
http://msdn.microsoft.com/en-us/library/vstudio/tsyyf0yh.aspx
The issue was apparent when looking at the .zip file created by the Export Template command. The .cs file contained within the template .zip read:
namespace $rootnamespace$
{
class $safeitemname$ : MonoCross.Navigation.$safeitemname$
{
public override void OnAppLoad()
{
//Do the work
}
}
}
The fix to get my template working was to edit the .cs file manually and replace the last $safeitemname$ with MXApplication and then stick the .cs file back in the .zip file where it came from.
My question is very similar to this one, only that the answer and work-around are not working for me. Also I am in Visual Studio 2012.
I have a VSPackage which is referencing another project, which is dependent on other dlls. Everytime time I run my package in debug I get an exception that the other dlls cannot be found. They are in the output directory, and they are signed.
I tried referencing them directly by the VSPackage project to no avail.
Thoughts?
This problem exists because Visual Studio is not looking for assemblies in a folder of your extension if your extension has no explicit dependence on these assemblies. For example, dependences set in a configuration file (IoC config) or in xaml code. I know three solutions to this problem:
You can deploy these assemblies in the GAC and Visual Studio will load them. This method is good if you use a third-party library that built for use in the GAC (for example, MS Enterprise Library). But VSIX Deployment Package does not allow installing assemblies in the GAC, you can use the MSI installer.
For VSPackages for Visual Studio 2010/2012 you can use ProvideBindingPath attribute. The path where your extension located will be added to the paths that Visual Studio uses to find dependent assemblies. If your extension doesn't include a VSPackage, you can add this attribute to any public class (see here).
[ProvideBindingPath]
public class MyVsPackage : Package
{ /* ... */ }
You can manually resolve assembly names. To do this, you need to subscribe to the AssemblyResolve event and you need to return required assemblies from a handler. This is the most flexible way, if you cannot use the previous methods, this is especially for you.
In my IntelliDebugger project, I wrote a class ManualAssemblyResolver for it:
using System;
using System.Reflection;
namespace IntelliEgg.Debugger.Utility
{
public class ManualAssemblyResolver : IDisposable
{
public ManualAssemblyResolver(Assembly assembly)
{
if (assembly == null)
throw new ArgumentNullException("assembly");
_assemblies = new[] {assembly};
AppDomain.CurrentDomain.AssemblyResolve += OnAssemblyResolve;
}
public ManualAssemblyResolver(params Assembly[] assemblies)
{
if (assemblies == null)
throw new ArgumentNullException("assemblies");
if (assemblies.Length == 0)
throw new ArgumentException("Assemblies should be not empty.", "assemblies");
_assemblies = assemblies;
AppDomain.CurrentDomain.AssemblyResolve += OnAssemblyResolve;
}
public void Dispose()
{
AppDomain.CurrentDomain.AssemblyResolve -= OnAssemblyResolve;
}
private Assembly OnAssemblyResolve(object sender, ResolveEventArgs args)
{
foreach (Assembly assembly in _assemblies)
{
if (args.Name == assembly.FullName)
{
return assembly;
}
}
return null;
}
private readonly Assembly[] _assemblies;
}
}
This class must be created before the first call to the problem assembly (e.g., in Package::Initialize() method)