How to stop monodevelop add **-noconfig** compilation option? - mono

I tried to compile this moq example on Mono 2.8.2, targeting .NET 3.5., with MonoDevelop 2.4.1
using System;
using Moq;
namespace moq_demo
{
public interface IFoo
{
bool DoSomething(string n);
}
class MainClass
{
public static void Main (string[] args)
{
var mock = new Mock<IFoo>();
mock.Setup(foo => foo.DoSomething("ping")).Returns(true);
}
}
}
I got 3 compile error:
/home/rupert/Projects/moq_demo/moq_demo/Main.cs(36,36): Error CS1660: Cannot convert lambda expression' to non-delegate typeSystem.Linq.Expressions.Expression>' (CS1660) (moq_demo)
/home/rupert/Projects/moq_demo/moq_demo/Main.cs(30,30): Error CS1502: The best overloaded method match for `Moq.Mock.Setup(System.Linq.Expressions.Expression>)' has some invalid arguments (CS1502) (moq_demo)
/home/rupert/Projects/moq_demo/moq_demo/Main.cs(30,30): Error CS1503: Argument #1' cannot convertanonymous method' expression to type `System.Linq.Expressions.Expression>' (CS1503) (moq_demo)
I've completely no idea what does these means. Anyone knows what might cause the problem?
Edit
I tried to compile it directly with command
gmcs Main.cs /r:Moq.dll
and it compiled. So it must be caused by some additional compile option introduced by MonoDevelop. By export make file, I confirmed my guess. This compile command
gmcs -noconfig -codepage:utf8 -warn:4 -out:bin/Release/moq_demo.exe -target:exe './Main.cs' './AssemblyInfo.cs' -r:System -r:Moq.dll
will trigger the compile error. By eliminating these options one by one, I found it's -noconfig that caused all the problem.
So the problem no became : How to stop monodevelop add -noconfig compilation option?

The -noconfig option means you must supply all the assembly references on the command line. Your compile error is because you must add a reference to System.Core in monodevelop to satisfy the lambda expression types you've used.
$ gmcs -noconfig test.cs -r:Moq.dll -r:System.dll -r:System.Core.dll
works for me.

Related

Registering .net assembly for COM succeeds with regasm but fails using RegistrationServices.RegisterAssembly

This is one of the strangest issue I have encountered.
There is a .net assembly, which is exposed to COM.
If you register it with regasm /codebase my.dll - it is sucessfully registered, and can be used.
However, if you register it from code using RegistrationServices.RegisterAssembly() :
[...]
RegistrationServices regSvcs = new RegistrationServices();
Assembly assembly = Assembly.LoadFrom(path);
// must call this before overriding registry hives to prevent binding failures on exported types during RegisterAssembly
assembly.GetExportedTypes();
using (RegistryHarvester registryHarvester = new RegistryHarvester(true))
{
// ******** this throws *********
regSvcs.RegisterAssembly(assembly, AssemblyRegistrationFlags.SetCodeBase);
}
Then it throws exception:
Could not load file or assembly 'Infragistics2.Win.UltraWinTree.v9.2, Version=9.2.20092.2083,
Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb' or one of its dependencies.
Provider type not defined. (Exception from HRESULT: 0x80090017)
This error has very little resource on the net, and looks like related to some security(?) cryptography(?) feature.
After long-long hours, I figured out what causes this (but don't know why):
If there is a public class with a public constructor in the assembly with a parameter UltraTree (from the referenced assembly 'Infragistics2.Win.UltraWinTree.v9.2'), then you cannot register from code, but with regasm only.
When I changed the have a public function Init(UltraTree tree), then it works, I can register from code. So:
// regasm: OK / RegistrationServices.RegisterAssembly(): exception
public class Foo
{
public Foo(UltraWinTree tree) { .. }
}
Foo foo = new Foo(_tree);
-------------- vs --------------
// regasm: OK / RegistrationServices.RegisterAssembly(): OK
public class Foo
{
public Foo() {}
public void Init(UltraWinTree tree) { .. }
}
Foo foo = new Foo();
foo.Init(_tree);
So I could workaround by passing UltraWinTree in a new Init() function instead of constructor, but this is not nice, and I want to know the reason, what the heck is going on?
Anyone has any idea? Thanks.
PS:
Okay, but why we want to register from code? As we use Wix to create installer, which uses heat.exe to harvest registry entries (which are added during asm registration), so heat.exe does assembly registration from code.
I've been dealing with this for years so this is the only answer you need to read:
Heat calls regasm /regfile. So does InstallShield when you tell it to. If you read this page:
https://learn.microsoft.com/en-us/dotnet/framework/tools/regasm-exe-assembly-registration-tool
There's a very important caveat in the remarks section.
You can use the /regfile option to generate a .reg file that contains
the registry entries instead of making the changes directly to the
registry. You can update the registry on a computer by importing the
.reg file with the Registry Editor tool (Regedit.exe). The .reg file
does not contain any registry updates that can be made by user-defined
register functions. The /regfile option only emits registry entries
for managed classes. This option does not emit entries for TypeLibIDs
or InterfaceIDs.
So what to do? Use Heat to generate most of the metadata. Then on a clean machine, (snapshot VM best) us a registry snapshot and compare tool such as InCntrl3 or InstallWatch Pro and sniff out what additional meta regasm writes to the registry. Finally massage that into your Wxs code.
Then on a cleam machine test the install. The result should work and not require any custom actions in the install.

Moshi - issue serializing library class after minification

Recently ran into an issue with library, which uses moshi to create runtime TypeAdapter for serialization/deserialization. The library seems to work fine with R8 disabled, but after enabling it I ran into an error message:
Fatal Exception: java.lang.IllegalArgumentException: Cannot serialize Kotlin type org.walletconnect.impls.WCSessionStore$State. Reflective serialization of Kotlin classes without using kotlin-reflect has undefined and unexpected behavior. Please use KotlinJsonAdapterFactory from the moshi-kotlin artifact or use code gen from the moshi-kotlin-codegen artifact.
for class org.walletconnect.impls.WCSessionStore$State
for java.util.Map<java.lang.String, org.walletconnect.impls.WCSessionStore$State>
The solution seems to be defining keepclass R8 rule and it works.
But, prior to adding R8 rule, what bothers me is that if I decompile the minified binary I can see that the class in question (WCSessionStore$State) is not minified at all and I can clearly see that it's referenced when constructing the adapter:
public final class C12848a implements WCSessionStore {
public C12848a(File file, C10727r rVar) {
C11124p.m43616g(file, "storageFile");
C11124p.m43616g(rVar, "moshi");
this.f32438c = file;
this.f32436a = rVar.mo25906d(C10747u.m42144j(Map.class, String.class, WCSessionStore.State.class));
.
.
.
public interface WCSessionStore {
public State(Session$Config session$Config, Session$PeerData session$PeerData, Session$PeerData session$PeerData2, Long l, String str, List list, Long l2) {}
.
.
.
Also worth noting would be, that I'm running android.enableR8.fullMode=true
Is this expected behavior? Is the R8 rule the only way to get around this?

grammar.y error happended when compiled Cobalt

When compile Cobalt, the following error happend, is there anyone who knows why?
It said the 'ShadowType' is not a class or namespace in grammy.y:3421, I did not know what is used for grammy.y, and try to trace and modify the code, it does not work.
grammar.y error details
Your issue is that C++ version before C++0x does not support ShadowType::kBoxShadow(member in enum type) use at all, you can change the cflags_cc from "-std=gnu++98" to "-std=gnu++0x"in third_party/starboard/linux/shared/gyp_configuration.gypi, and try again.

Mockolate Verify Error: Illegal override.. after Flex SDK 4.10 update

Since we upgraded the flex sdk in our application to 4.10 we've been running into Verify Errors while running unit tests that use mockolate.
They seem to occur when mocking an interface where a ByteArray is used in a method signature.
Example interface:
public interface IFileSystemHelper {
function loadFileContents(path:String):ByteArray;
}
Example test class:
public class SomeTest {
[Rule]
public var mockolateRule:MockolateRule = new MockolateRule();
[Mock]
public var fileHelper:IFileSystemHelper;
public function SomeTest() {
}
[Test]
public function testMethod():void {
// ...
}
}
When compiling and running the test with flexmojos 6.0.1 the following error is thrown:
VerifyError: Error #1053: Illegal override of
IFileSystemHelper8F2B5D281827800A824B85B588C6F2A08AE814ED in
mockolate.generated.IFileSystemHelper8F2B5D281827800A824B85B588C6F2A08AE814ED
My initial suspicion was an sdk version problem with playerglobal (or airglobal in our case) so i recompiled mockolate (and flexunit) with sdk 4.10, without any result.
The only thing that seems to work is to remove the ByteArray type from the method signature... but that's not really an option :-) (and this has never been a problem before)
Is there anyone who has had a similar issue?
Thanks
This problem usually occurs when compiling different parts of your application with different versions of the sdk.
I would recommend to have a look at the output of "mvn dependency:tree" as this should output all dependencies (direct and transitive ones). Perhaps this will help you find where the wrong version is comming from.

Squishit.Less doesn't do anything

I've used package manager to install Squishit.Less 0.9.3, and I have two files
style.less - #import "test.less";
test.less - body{background-color: pink;}.
In my page I have:
<%= Bundle.Css().Add("~/less/style.less").ForceRelease().Render("~/less/combined.css") %>
But the output I get is: #import"test.less"; - the less processor hasn't tried to get the import for some reason?
I've tried ProcessImports but that made no difference.
I just verified in a sample project that it works correctly.
You should NOT need to call ProcessImports - the less preprocessor should do this automatically. ProcessImports is for #imports in standard CSS, which aren't processed by default.
I suspect what happened is that NuGet didn't add the file that registers the preprocessor. As a result the less preprocessor is never called. If you look under App_Start you should see a file called SquishItLess.cs with the following contents:
[assembly: WebActivator.PreApplicationStartMethod(typeof(MyProject.App_Start.SquishItLess), "Start")]
namespace MyProject.App_Start
{
using SquishIt.Framework;
using SquishIt.Less;
public class SquishItLess
{
public static void Start()
{
Bundle.RegisterStylePreprocessor(new LessPreprocessor());
}
}
}
If this file is missing, you can either add it or add the Bundle.RegisterStylePreprocessor line in your Global.asax.cs' Application_Start method.
If you're installing to a VB project this is a known issue (https://github.com/jetheredge/SquishIt/issues/232) and will be addressed when the plug is pulled on .net 3.5 support.