Is VisualStudio MacOS using a different F# compiler than dotnet / Rider? - macos

I'm trying to compile FsPickler on Mac.
The command line compilation works very well:
dotnet build -c Release
but when compiling the same project in Visual Studio (version 8.8), I start to get some compilation errors which have to do with the parsing of the files, which is really odd.
like this kind of errors:
the code it can't compile is this:
let currentLoadContext = lazy(
match Type.GetType "System.Runtime.Loader.AssemblyLoadContext" with
| null -> None
| ty ->
match ty.GetProperty "Assemblies" with
| null -> None // property not available in netcoreapp < 3.0
| assembliesProperty ->
let loadContextM = ty.GetMethod("GetLoadContext", BindingFlags.Public ||| BindingFlags.Static, null, [|typeof<Assembly>|], null)
let loadFromNameM = ty.GetMethod("LoadFromAssemblyName", BindingFlags.Public ||| BindingFlags.Instance, null, [|typeof<AssemblyName>|], null)
let asm = Assembly.GetExecutingAssembly()
let currentLoadContext = loadContextM.Invoke(null, [|asm|])
let getContextAssemblies () = assembliesProperty.GetValue(currentLoadContext) :?> seq<Assembly> |> Seq.toArray
let loadFromAssemblyName (an : AssemblyName) = loadFromNameM.Invoke(currentLoadContext, [|an|]) :?> Assembly
Some {| LoadContext = currentLoadContext ; GetCurrentAssemblies = getContextAssemblies ; LoadFromAssemblyName = loadFromAssemblyName |})
but it's not really relevant to the problem.
When I look at the details, I see that:
Target CoreCompile:
/Library/Frameworks/Mono.framework/Versions/6.12.0/lib/mono/fsharp/fsc.exe -o:obj/Debug/netstandard2.0/FsPickler.dll
and I'm now questioning: why do I even have Mono installed and what does Mono have to do with compiling the .net code with Visual Studio?
If I compile the same project with Rider, it works, with the command line, it works but with Visual Studio I get the errors above and a compiler coming from a Mono folder.
Can anyone shed some light as to why Mono is involved and if there are two versions of the compiler?

Related

failed to resolve: maybe a missing crate `image`? Rust

I'm attempting to start my first project in Rust using VScode. I added the '''image = "0.24.5"''' to the dependencies section of the Cargo.toml file, built the project with cargo build. However, whenever I try and run the file I get an error that says:
error[E0433]: failed to resolve: maybe a missing crate `image`?
--> main.rs:1:5
|
1 | use image::io::Reader;
| ^^^^^ maybe a missing crate `image`?
|
= help: consider adding `extern crate image` to use the `image` crate
This is the main file:
use image::io::Reader;
fn main() {
println!("Hello, world!");
}
Cargo.toml
[package]
name = "imaging"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
image = "0.24.5"
Not quite sure why I'm getting this error. My guess is that it may be that VScode is unable to find the dependency.

How to use serde_json in pallet?

On using serde_json in my pallet dependency it throws this throws these error:-
``
#[weight=10_000]
pub fn insert_data_class(origin,app_id:Vec<u8>,db_id:Vec<u8>,cid:Vec<u8>,data:Vec<u8>,signature:H512)->DispatchResult{
let caller = ensure_signed(origin)?;
let app_data = alioth_register::Module::<T>::check_ownership(&caller,&app_id);
ensure!(app_data.0,Error::<T>::AppNotFound);
let data_str = String::from_utf8(data.clone()).unwrap();
let data_json = json!(data_str);
let uid:Vec<u8> = data_json["uid"].to_string().as_bytes().to_vec();
//let uuid_str = data_json["uuid"].to_string();
let uuid:Vec<u8> = data_json["uuid"].to_string().as_bytes().to_vec();
let data1 = data.clone();
let data1 = String::from_utf8(data1).unwrap();
let user_data = alioth_users::Module::<T>::check_user_extern(&uuid,&app_id);
ensure!(user_data.0,Error::<T>::UserNotFound);
let class_data = alioth_class::Module::<T>::check_class(&db_id,&cid);
ensure!(class_data.0,Error::<T>::ClassOrDatabaseNotFound);
//I needed a public key for this purpose we are going to write a function in alioth-users
let pub_key_ref:(bool,H256) = alioth_users::Module::<T>::get_public_key(&uuid,&app_id);
ensure!(pub_key_ref.0,Error::<T>::ObjectNotCreated);
//now we are going to verify the signature for the further transaction
ensure!(sp_io::crypto::sr25519_verify(&Signature::from_h512(signature),data1.as_bytes(),&Public::from_h256(pub_key_ref.1)),Error::<T>::SignatureNotVerified);
//its over now we are going ahead to check the uniqness of data and insert it later.
let data_from_self = Self::check_obj_store(&uid,&cid);
ensure!(!data_from_self.0,Error::<T>::DataIsNotUnique);
let struct_data = ObjectData{
duid:uid,
object:data,
};
if data_from_self.1==0{
let vec_data = vec![struct_data];
<ObjectStore>::insert(cid,vec_data);
Self::deposit_event(Event::ObjectCreated());
}
else{
let mut vec_data = <ObjectStore>::get(&cid);
vec_data.insert(vec_data.len(),struct_data);
<ObjectStore>::insert(cid,vec_data);
Self::deposit_event(Event::ObjectCreated());
}
Ok(())
}**this code uses serde_json::json macro**
error: failed to run custom build command for node-template-runtime v3.0.0 (/home/corteri/Desktop/blockchain/new_tmp/substrate-node-template/runtime)
Caused by:
process didn't exit successfully: /home/corteri/Desktop/blockchain/new_tmp/substrate-node-template/target/debug/build/node-template-runtime-e56bc02a2834241f/build-script-build (exit status: 1)
--- stdout
Information that should be included in a bug report.
Executing build command: "rustup" "run" "nightly" "cargo" "-Zfeatures=build_dep" "rustc" "--target=wasm32-unknown-unknown" "--manifest-path=/home/corteri/Desktop/blockchain/new_tmp/substrate-node-template/target/debug/wbuild/node-template-runtime/Cargo.toml" "--color=always" "--release"
Using rustc version: rustc 1.56.0-nightly (b7404c898 2021-09-03)
--- stderr
warning: flag -Z features has been stabilized in the 1.51 release, and is no longer necessary
The new feature resolver is now available by specifying resolver = "2" in Cargo.toml.
See https://doc.rust-lang.org/nightly/cargo/reference/features.html#feature-resolver-version-2 for more information.
Compiling getrandom v0.2.1
error: target is not supported, for more information see: https://docs.rs/getrandom/#unsupported-targets
--> /home/corteri/.cargo/registry/src/github.com-1ecc6299db9ec823/getrandom-0.2.1/src/lib.rs:214:9
|
214 | / compile_error!("target is not supported, for more information see:
215 | | https://docs.rs/getrandom/#unsupported-targets");
| |_________________________________________________________________________^
error[E0433]: failed to resolve: use of undeclared crate or module imp
--> /home/corteri/.cargo/registry/src/github.com-1ecc6299db9ec823/getrandom-0.2.1/src/lib.rs:236:5
|
236 | imp::getrandom_inner(dest)
| ^^^ use of undeclared crate or module imp
For more information about this error, try rustc --explain E0433.
error: could not compile getrandom due to 2 previous errors
getrandom/js feature needs to be activated in your Cargo.toml:
# We enable it only for web-wasm check
# See https://docs.rs/getrandom/0.2.1/getrandom/#webassembly-support
getrandom = { version = "0.2", features = ["js"] }
(I don't think this is a serde_json specific error btw)

Unable to compile LLVM 5.0.0 with MSVC 14.0

I am trying to compile LLVM 5.0.0 from source on Windows 10 with Visual Studio 14.0 (2015).
I used the following cmake flags:
CMAKEOPTIONS += -D PYTHON_EXECUTABLE:PATH=$(PYTHON_PATH)/bin/python
CMAKEOPTIONS += -D LLVM_ENABLE_TERMINFO=0
CMAKEOPTIONS += -D LLVM_ENABLE_EH=1
CMAKEOPTIONS += -D LLVM_ENABLE_RTTI=1
CMAKEOPTIONS += -D LLVM_ENABLE_ASSERTIONS:BOOL=ON -D LLVM_ABI_BREAKING_CHECKS:STRING="FORCE_OFF"
The compilation fails with:
Severity Code Description Project File Line Suppression State Error
C2039
'iterator_facade_base,0,1>
,std::forward_iterator_tag,llvm::PHINode const ,__int64,llvm::PHINode const *,llvm::PHINode const &>': is not a member of
'llvm::BasicBlock::phi_iterator_impl' (compiling source
file
S:\authama\3p-tmw\3p\derived\win64\LLVM5\llvm-debug\lib\Target\AMDGPU\Utils\AMDGPUBaseInfo.cpp)
LLVMAMDGPUUtils
s:\authama\3p-tmw\3p\derived\win64\llvm5\llvm-debug\include\llvm\ir\basicblock.h
294
Which points to:
290 bool operator==(const phi_iterator_impl &Arg) const { return PN == Arg.PN; }
291
292 PHINodeT &operator*() const { return *PN; }
293
294 using phi_iterator_impl::iterator_facade_base::operator++;
295 phi_iterator_impl &operator++() {
296 assert(PN && "Cannot increment the end iterator!");
297 PN = dyn_cast<PHINodeT>(std::next(BBIteratorT(PN)));
298 return *this;
299 }
The source compiles with GCC 4.9/Debian8, so I am guessing I missed something to do with setting up the compiler correctly.
Any suggestions for me to try?
As I was once told by one of the VCPP developers, "please upgrade to 2017; 2015 is an ancient bug farm." Less than useful in many instances, but if you're using the community version of 2015 (or are in a position to upgrade pro/enterprise 2015 to 2017), try upgrading to 2017 and see if that fixes it.
I had a similar problem with 2015 that turned out to be an actual compiler bug and that appears to be the issue here as well.

How can I use erl_lint to syntax check an Erlang module?

I'm trying to use erl_lint() to build a simple Erlang syntax and style checker. I've gotten far enough to load the file and parse it into Forms and to get erl_lint to partially understand it, but then erl_lint complains about undefined functions that are defined. What am I doing wrong?
erlint.erl :
-module(erlint).
-export([lint/1]).
% based on http://stackoverflow.com/a/28086396/13675
lint(File) ->
{ok, B} = file:read_file(File),
Forms = scan(erl_scan:tokens([],binary_to_list(B),1),[]),
F = fun(X) -> {ok,Y} = erl_parse:parse_form(X), Y end,
erl_lint:module([F(X) || X <- Forms],File).
scan({done,{ok,T,N},S},Res) ->
scan(erl_scan:tokens([],S,N),[T|Res]);
scan(_,Res) ->
lists:reverse(Res).
hello.erl :
-module(hello).
-export([hello_world/0]).
hello_world() -> io:fwrite("hello, world\n").
attempt to use :
1> c(erlint).
{ok,erlint}
2> erlint:lint("hello.erl").
{error,[{"hello.erl",
[{2,erl_lint,{undefined_function,{hello_world,0}}}]}],
[]}
I'm not sure this approach fits with your overall plan, but you could instead compile the input file, extract its abstract forms from the resulting beam, and pass them to erl_lint:
-module(erlint).
-export([lint/1]).
lint(File) ->
{ok,_,Bin} = compile:file(File,[debug_info,binary]),
{ok,{_,[{abstract_code,{_,AC}}]}} = beam_lib:chunks(Bin,[abstract_code]),
erl_lint:module(AC,File).
Let's change your hello.erl to include an unused variable:
-module(hello).
-export([hello_world/0]).
hello_world() ->
X = io:fwrite("hello, world\n").
We see that this version of erlint:lint/1 correctly reports it:
1> erlint:lint("hello.erl").
{ok,[{"hello.erl",[{5,erl_lint,{unused_var,'X'}}]}]}
If you need them for your overall purposes, note that you can retrieve source code forms from the abstract forms variable AC by calling erl_syntax:form_list(AC).

Swift 2.0, Xcode 7 issue

I was using RAMAnimatedTabBarController Module from here:
https://github.com/Ramotion/animated-tab-bar
I developed my entire application in swift 1.2 using Xcode 6 and the app was running perfectly . I wanted to try out "side loading" of my app using Xcode 7 which has swift 2.0. I had too many errors and I managed to solve most of the errors but three.
1) This line of code which is from that RAMAnimatedTabBarController module is throwing an error saying the function can't be evoked, when this perfectly compiled in Xcode 6:
var constranints = NSLayoutConstraint.constraintsWithVisualFormat(formatString,options:NSLayoutFormatOptions.DirectionRightToLeft,metrics: nil,views: containersDict as [NSObject : AnyObject])
the compiler error for this was:
Cannot invoke 'constraintsWithVisualFormat' with an argument list of
type '(String, options: NSLayoutFormatOptions, metrics: nil, views:
[NSObject : AnyObject])'
2) Another unusual error was thrown:
linker command failed with exit code 1 (use -v to see invocation)
3) And another:
(null): error: cannot parse the debug map for
"/Users/Rakshith/Library/Developer/Xcode/DerivedData/Blubot-heabwwmhqxxvctaabxkwcpgzsadx/Build/Intermediates/SwiftMigration/Blubot/Products/Debug-iphonesimulator/BlubotTests.xctest/BlubotTests":
No such file or directory
What is actually wrong with my project? It is still set to iOS 8.3.
Disable BitCode
Build Settings -> BitCode
I managed to correct the 2nd and 3rd error which most of you probably will face when you're running Xcode 7 Beta as well as Xcode 6.
Just solve these two errors by following the steps mentioned in this tread:
Xcode Version 6.1 (6A1030) - Apple Match O-Linker Error - Building
Try this method:
func createViewContainers() -> [String: UIView] {
var containersDict = [String: UIView]()
guard let tabBarItems = tabBar.items else
{
return containersDict
}
let itemsCount: Int = tabBarItems.count - 1
for index in 0...itemsCount {
let viewContainer = createViewContainer()
containersDict["container\(index)"] = viewContainer
}
var formatString = "H:|-(0)-[container0]"
for index in 1...itemsCount {
formatString += "-(0)-[container\(index)(==container0)]"
}
formatString += "-(0)-|"
let constranints = NSLayoutConstraint.constraintsWithVisualFormat(formatString,
options:NSLayoutFormatOptions.DirectionRightToLeft,
metrics: nil,
views: containersDict)
view.addConstraints(constranints)
return containersDict
}
how about to change the small code from "containersDict as [NSObject : AnyObject]" to "containersDict as [String : AnyObject]".
then I solved the issue above method.

Resources