Visual Studio 2013 - Class Diagram strangeness - visual-studio-2013

VS2013 Premium update 3. When I right click on a .cs and do View Class Diagram, VS seems to be putting all entities on 1 .cd file. Even though they are in a different Namespace.
Is this standard behaviour, or is something stuffed in this solution?
Relevant section of .csproj
Source https://github.com/djhmateer/AltNetDI
<ItemGroup>
<Compile Include="Example8.cs" />
<Compile Include="Example7.cs" />
<Compile Include="Example6.cs" />
<Compile Include="Example5.cs" />
<Compile Include="Example2.cs" />
<Compile Include="Example6Mike.cs" />
<Compile Include="Example1.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="ClassDiagram1.cd" />
<None Include="packages.config" />
</ItemGroup>
Example1.cs
namespace AltNetDI1 {
class CompositionRoot {
public static void EMain() {
// Instantiating the objects we will need
IReader reader = new TextFileReader();
IWriter writer = new ConsoleWriter();
// Pass objects to our Appliction via Dependency Injection
IApplication application = new Application(reader, writer);
application.Run();
}
}
Example2.cs
namespace AltNetDI2 {
class CompositionRoot {
public static void EMain() {
IReader reader = new TextFileReader();
//IWriter writer = new ConsoleWriter();
// Decorating ConsoleWriter with a WriterLogger
IWriter writer = new WriterLogger(new ConsoleWriter());
// Pass objects to our Appliction via Dependency Injection
IApplication application = new Application(reader, writer);
application.Run();
}
}

Related

minio upgrade issue xml invalid

Task: Trying to upgrade from minio.netcore 1.1.1 client to minio client 3.1.13
Problem: When i try to create a bucket with the new client I get the following excpetion thrown:
MinIO API responded with message=The XML you provided was not well-formed or
did not validate against our published schema
I've tested in isolation from the rest of my code and can't see what the issue is:
using System;
using System.Threading.Tasks;
namespace ConsoleApp3
{
class Program
{
static async Task Main(string[] args)
{
Console.WriteLine("Hello World!");
var client = new Minio.MinioClient("{serverIpAddress}:9000", "myaccesskey", "mysecretkey");
var bucketid = Guid.NewGuid().ToString();
await client.MakeBucketAsync(bucketid,"uk-st-1");
var result = await client.BucketExistsAsync(bucketid);
}
}
}
and my csproj is switching between these 2 nugets:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Minio" Version="3.1.13" />
<!--<PackageReference Include="Minio.NetCore" Version="1.1.1" />-->
</ItemGroup>
</Project>
I've tried catching the traffic and the XML it produces for both nugets is this:
<?xml version="1.0" encoding="utf-8"?>
<q1:CreateBucketConfiguration xmlns:q1="http://s3.amazonaws.com/doc/2006-03-01/">
<q1:LocationConstraint>uk-st-1</q1:LocationConstraint>
</q1:CreateBucketConfiguration>

Does Xamarin support class library project reference nesting, generating an AndroidManifest.xml for components in nested references?

Does Xamarin support multiple levels of project reference nesting, where the referenced project includes Android components intended for the AndroidManifest.xml?
For example: AndoidXamarin App > ClassLibrary1 > (which declares a Service) ClassLibrary2 (which also declares a Service):
// ClassLibrary1:
// Referenced by the XamarinApp
// References ClassLibrary2
namespace ClassLibrary1
{
[Service(Exported = true, Name = "com.company.test." + nameof(ClassLib1Service))]
public class ClassLib1Service : Service
{
public override IBinder OnBind(Intent intent) => throw new NotImplementedException();
}
}
// ClassLibrary2
// Referenced only by ClassLibrary1
namespace ClassLibrary2
{
[Service(Exported = true, Name = "com.company.test." + nameof(ClassLib2Service))]
public class ClassLib2Service : Service
{
public override IBinder OnBind(Intent intent) => throw new NotImplementedException();
}
}
// The generated `AndroidManifest.xml` only includes the Service defined in ClassLibrary1.
<application android:allowBackup="true" android:icon="#mipmap/ic_launcher" android:label="#string/app_name" android:roundIcon="#mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="#style/AppTheme" android:name="android.app.Application">
<activity android:label="#string/app_name" android:theme="#style/AppTheme" android:name="crc64a7a6b04b89628087.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service android:exported="true" android:name="com.company.test.ClassLib1Service" />
<provider android:name="mono.MonoRuntimeProvider" android:exported="false" android:initOrder="1999999999" android:authorities="com.company.test.mono.MonoRuntimeProvider.__mono_init__" />
</application>

Having trouble getting webapi selfhost working with ninject

I'm trying to get Ninject to work with a project that is using self a hosted WebApi connection.
I've installed the nuget package Microsoft ASP.NET Web API 2.2 Self Host (Microsoft.AspNet.WebApi.SelfHost) along with Ninject.Web.Common.Selfhost.
The console app seems to load up correctly, but I only seem to get a connection error when hitting my URL (http://localhost:8081/api/hello). I have a similar test app that is not using Ninject that works correctly.
I'm trying to follow this post: https://github.com/ninject/Ninject.Web.Common/wiki/Setting-up-a-self-hosted-web-application
Am I missing something to get this going? I originally tried using the package Microsoft.AspNet.WebApi.OwinSelfHost but could not get it functioning because of various errors. If this is what I need to be using, I can revisit this.
public class HelloController : ApiController
{
public string Get()
{
return "Hello, world!";
}
}
class Program
{
static void Main(string[] args)
{
var webApiConfiguration = new HttpSelfHostConfiguration("http://localhost:8081");
webApiConfiguration.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional });
var mSelfHost = new NinjectSelfHostBootstrapper(CreateKernel, webApiConfiguration);
mSelfHost.Start();
Console.ReadLine();
}
private static IKernel CreateKernel()
{
var mKernel = new StandardKernel();
mKernel.Load(Assembly.GetExecutingAssembly());
return mKernel;
}
}
Here are the packages I have installed:
<packages>
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.2" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.Core" version="5.2.2" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.SelfHost" version="5.2.2" targetFramework="net45" />
<package id="Newtonsoft.Json" version="6.0.8" targetFramework="net45" />
<package id="Ninject" version="3.2.2.0" targetFramework="net45" />
<package id="Ninject.Web.Common" version="3.2.3.0" targetFramework="net45" />
<package id="Ninject.Web.Common.Selfhost" version="3.2.3.0" targetFramework="net45" />
</packages>
I was able to solve this by adding Ninject.Web.WebApi.SelfHost first. This loaded the appropriate WebApi packages automatically. Before I was loading the WebApi packages myself and then adding Ninject.

Install Spring through maven

I am new in using maven, I am having a java class as follow:
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class DecoupledDataReaderClient {
private IReader reader = null;
private ApplicationContext ctx = null;
public DecoupledDataReaderClient() {
ctx = new ClassPathXmlApplicationContext("basics-reader-beans.xml");
}
private String fetchData() {
reader = (IReader) ctx.getBean("reader");
return reader.read();
}
public static void main(String[] args) {
DecoupledDataReaderClient client = new DecoupledDataReaderClient();
System.out.println("Example 1.3: Got data: " + client.fetchData());
}
}
I am having an ant built file as follow:
<target name="init">
<artifact:dependencies pathId="dependency.classpath">
<dependency
groupId="org.springframework"
artifactId="spring-context"
version="3.2.1.RELEASE"
/>
</artifact:dependencies>
</target>
<target name="compile" depends="init">
<mkdir dir="classes"/>
<javac srcdir="${src}" destdir="${dest}" includeantruntime="false">
</javac>
</target>
<target name="jar" depends="compile">
<mkdir dir="${build}"/>
<jar destfile="${jar}" basedir="${dest}">
<manifest>
<attribute name="Main-Class" value="src.DecoupledDataReaderClient"/>
</manifest>
</jar>
</target>
<target name="run" depends="jar">
<java jar="${jar}" fork="true"/>
</target>
When I run the ant built file I get the error:
error: package org.springframework.context does not exist
error: package org.springframework.context.support does not exist
Is there anything else I have to include in my ant file to make it run?

elmah with mvc is logging twice

Everytime Elmah logs an error the error is logged twice. 100% identical with exact the same Timestamp.
I have no special configuration in the web.config.
I have created a ElmahHandleErrorAttribute an added two filters:
filters.Add(new ElmahHandleErrorAttribute {
ExceptionType = typeof(System.Data.Common.DbException),
// DbError.cshtml is a view in the Shared folder.
View = "DbError",
Order = 2
});
filters.Add(new ElmahHandleErrorAttribute {
ExceptionType = typeof(Exception),
// DbError.cshtml is a view in the Shared folder.
View = "Error",
Order = 3
});
Some Snippets from web.config:
<httpModules>
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" />
<add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" />
<add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" />
</httpModules>
and
<modules runAllManagedModulesForAllRequests="true">
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" preCondition="managedHandler" />
<add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" preCondition="managedHandler" />
<add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" preCondition="managedHandler" />
</modules>
In the ElmaHandleErrorAttribute this code:
public override void OnException(ExceptionContext context) {
base.OnException(context);
if (!context.ExceptionHandled
|| TryRaiseErrorSignal(context)
|| IsFiltered(context))
return;
LogException(context);
}
I have searched a lot, but no solution fits to my problem. No double entries in web.config or something like this.
It's no big problem, but it's annoying.
thx in advance
©a-x-i
I had the same problem with my setup, so I made a ExceptionLogger class. Then added a static field to it to keep a list of the exceptions it logged. Then when the onException event hapens it checks for the last exception logged to avoid logging duplicates.
public class ExceptionLogger
{
public static List<Exception> loggedExceptions = new List<Exception>();
public static void LogException(Exception e) {
...
public override void OnException(ExceptionContext context)
{
base.OnException(context);
var e = context.Exception;
if (!e.Equals(ExceptionLogger.loggedExceptions.Last()))
{
ExceptionLogger.LogException(e);
}
}

Resources