Skip to content
This repository was archived by the owner on Nov 16, 2023. It is now read-only.

Fix assembly conflict issue - #208

Merged
Shweta Patil (Shwetap05) merged 10 commits into
masterfrom
FixAssemblyConflict
May 18, 2019
Merged

Shweta Patil (Shwetap05) merged 10 commits into
masterfrom
FixAssemblyConflict

Conversation

@Shwetap05

Copy link
Copy Markdown
Member

This PR brings lots of breaking changes

  • Added logic to handle assembly load conflicts that would work for both .Net Framework and .Net Core run times.
  • All of the type load logic is moved up so all the required type information is fetched before we actually proceed with generation.
  • Updated contracts for filters to include list of generation errors, that would be populated by each filter as it processes various xElements.
  • Added newtonsoft to handle serialization.
  • Other cascading changes.
  • Updated major version of the package.

#if !NETFRAMEWORK
var assemblyLoader = new AssemblyLoader.AssemblyLoader();
assemblyLoader.RegisterAssemblyPaths(contractAssemblyPaths);
var stringSchemaTypeInfo = new AssemblyLoader.AssemblyLoader().BuildSchemaTypeInfo(

@Shwetap05 Shweta Patil (Shwetap05) May 14, 2019 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SchemaTypeInfo [](start = 84, length = 14)

will update naming around SchemaTypeInfo to GenerationContext #Resolved

{
try
{
_assembliesLoadedByAssemblyName.Add(assemblyName);

@rwrife Ryan Rife (rwrife) May 14, 2019 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit. inconsistent use of the whitespace around the ( ), may want to apply one code style rule across all of the classes #Resolved

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes i had to disable resharper due to conflicting guidelines internal and externally, will update this.


In reply to: 284022572 [](ancestors = 284022572)

internal static class IListExtensions
{
/// <summary>
///

@rwrife Ryan Rife (rwrife) May 14, 2019 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit. empty summaries #Resolved

/// <param name="operation">The operation to be updated.</param>
/// <param name="element">The xml element representing an operation in the annotation xml.</param>
/// <param name="settings">The operation filter settings.</param>
/// <returns>The list of generation errors, if any produced when processing the filter."></returns>

@rwrife Ryan Rife (rwrife) May 14, 2019 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove "> from the end #Resolved

/// <param name="operation">The operation to be updated.</param>
/// <param name="element">The xml element representing an operation in the annotation xml.</param>
/// <param name="settings">The operation filter settings.</param>
/// <returns>The list of generation errors, if any produced when processing the filter."></returns>

@rwrife Ryan Rife (rwrife) May 14, 2019 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove "> #Resolved

/// <param name="operation">The operation to be updated.</param>
/// <param name="element">The xml element representing an operation in the annotation xml.</param>
/// <param name="settings">The operation filter settings.</param>
/// <returns>The list of generation errors, if any produced when processing the filter."></returns>

@rwrife Ryan Rife (rwrife) May 14, 2019 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove "> #Resolved

/// <param name="openApiDocument">The OpenAPI document to process.</param>
/// <param name="settings">The filter settings.</param>
public void Apply(
/// <returns>The list of generation errors, if any produced when processing the filter."></returns>

@rwrife Ryan Rife (rwrife) May 14, 2019 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"> #Resolved

/// <param name="element">The xml element representing an operation in the annotation xml.</param>
/// <param name="settings">The operation filter settings.</param>
public void Apply(OpenApiPaths paths, XElement element, PreProcessingOperationFilterSettings settings)
/// <returns>The list of generation errors, if any produced when processing the filter."></returns>

@rwrife Ryan Rife (rwrife) May 14, 2019 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"> #Resolved

/// <param name="element">The xml element representing an operation in the annotation xml.</param>
/// <param name="settings">The operation filter settings.</param>
public void Apply(OpenApiPaths paths, XElement element, PreProcessingOperationFilterSettings settings)
/// <returns>The list of generation errors, if any produced when processing the filter."></returns>

@rwrife Ryan Rife (rwrife) May 14, 2019 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"> #Resolved

/// </param>
/// <param name="settings"><see cref="PreProcessingOperationFilterSettings"/></param>
void Apply(OpenApiPaths paths, XElement element, PreProcessingOperationFilterSettings settings);
/// <returns>The list of generation errors, if any produced when processing the filter."></returns>

@rwrife Ryan Rife (rwrife) May 14, 2019 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"> #Resolved

/// <param name="element">The xml element representing an operation in the annotation xml.</param>
/// <param name="settings">The operation filter settings.</param>
public void Apply(OpenApiPaths paths, XElement element, PreProcessingOperationFilterSettings settings)
/// <returns>The list of generation errors, if any produced when processing the filter."></returns>

@rwrife Ryan Rife (rwrife) May 14, 2019 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

">...there are a few more of these in the returns comments, I'm not going to log on all of them :) #Resolved

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure will fix them all.


In reply to: 284025876 [](ancestors = 284025876)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made some suggestions. I don't see any blockers.

string assemblyName,
string assemblyVersion)
{
var assemblyPath = assemblyPaths.FirstOrDefault(path => path.EndsWith(assemblyName + ".dll"));

@JoshuaWhatley Joshua Whatley (JoshuaWhatley) May 9, 2019 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EndsWith? wouldn't we want an exact match? #WontFix

@JoshuaWhatley Joshua Whatley (JoshuaWhatley) May 10, 2019 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that the assemblyName passed in is not necessarily the full assemblyName. Could you update the param description so that this info is reflected. #Resolved

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

b/c we are checking against assembly path, so path would be like //test/test.dll and we watch to match test.dll with the path, so ends with.


In reply to: 282706378 [](ancestors = 282706378)

/// <param name="assemblyName">The assembly name to load.</param>
/// <param name="assemblyVersion">The assembly version to load.</param>
/// <returns>The assembly if able to load, otherwise null.</returns>
internal static Assembly TryLoadByVersion(

@JoshuaWhatley Joshua Whatley (JoshuaWhatley) May 9, 2019 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think TryLoadByName & TryLoadByVersion can be merged into one function where the version is an optional param. #Resolved

{
Version version = null;

var separatorIndex = args.Name.IndexOf(",", StringComparison.Ordinal);

@JoshuaWhatley Joshua Whatley (JoshuaWhatley) May 10, 2019 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have a comment describing the format of "args.Name". Will help clarify the separators in the following logic. #Resolved

return assembly;
}

assembly = AssemblyLoadUtility.TryLoadByName(assemblyPaths, assemblyName);

@JoshuaWhatley Joshua Whatley (JoshuaWhatley) May 10, 2019 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Loading twice? If this is required, please leave a comment on why. #Resolved

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this look s like copy paste error


In reply to: 282709466 [](ancestors = 282709466)

return;
}

if (crefFieldMap.ContainsKey(crefValue))

@JoshuaWhatley Joshua Whatley (JoshuaWhatley) May 14, 2019 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

|| with above #Resolved

/// <param name="element">The xml element representing an operation in the annotation xml.</param>
/// <param name="settings">The operation filter settings.</param>
public void Apply(OpenApiPaths paths, XElement element, PreProcessingOperationFilterSettings settings)
/// <returns>The list of generation errors, if any produced when processing the filter."></returns>

@JoshuaWhatley Joshua Whatley (JoshuaWhatley) May 14, 2019 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove "> at the end of the returns #Resolved

/// <param name="element">The xml element representing an operation in the annotation xml.</param>
/// <param name="settings">The operation filter settings.</param>
public void Apply(OpenApiPaths paths, XElement element, PreProcessingOperationFilterSettings settings)
/// <returns>The list of generation errors, if any produced when processing the filter."></returns>

@JoshuaWhatley Joshua Whatley (JoshuaWhatley) May 14, 2019 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"> #Resolved

{
"Empty example element",
XElement.Parse("<parent><example></example></parent>"),
new Dictionary<string,FieldValueInfo>(),

@JoshuaWhatley Joshua Whatley (JoshuaWhatley) May 14, 2019 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit space after , #Resolved

"Example with url",
XElement.Parse(
"<parent><example><summary>Test Example</summary><url>https://localhost/test.json</url></example></parent>"),
new Dictionary<string,FieldValueInfo>(),

@JoshuaWhatley Joshua Whatley (JoshuaWhatley) May 14, 2019 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit space after , #Resolved

@JoshuaWhatley Joshua Whatley (JoshuaWhatley) May 14, 2019 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do a search + replace all on <string,FieldValueInfo> as it seems this typo is in all the test changes. #Resolved

@@ -0,0 +1,412 @@
// ------------------------------------------------------------

@JoshuaWhatley Joshua Whatley (JoshuaWhatley) May 14, 2019 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file could use some comments to follow the logic to make it more approachable to open source contributions. #Resolved

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes i meant to do that, forgot.


In reply to: 284032234 [](ancestors = 284032234)

{
// First, populate the document variant info attributes using the document variant option.
var variantOptions = variantElement.Element(KnownXmlStrings.Options)?.Elements(KnownXmlStrings.Option);
var variantElements = element.Elements(KnownXmlStrings.Variant);

@rwrife Ryan Rife (rwrife) May 14, 2019 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you need a null check on 'element'? #Resolved

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure will do on all parameters


In reply to: 284036413 [](ancestors = 284036413)

InternalSchemaGenerationInfo schemaInfo = this.CrefToSchemaMap[key];
var internalSchemaInfo = new SchemaGenerationInfo
{
Schema = schemaInfo.Schema == null

@rwrife Ryan Rife (rwrife) May 14, 2019 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor readability issue with the ternary, consider:
Schema = (schemaInfo.Schema == null)
? blah
: other blah; #Resolved

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants